making a pdf from javascript code example

Example 1: javascript tutorial pdf

There is one really good pdf tutorial for javascript that I like.
Here's the link: https://goalkicker.com/JavaScriptBook

Example 2: html to pdf javascript

var doc = new jsPDF();          
var elementHandler = {
  '#ignorePDF': function (element, renderer) {
    return true;
  }
};
var source = window.document.getElementsByTagName("body")[0];
doc.fromHTML(
    source,
    15,
    15,
    {
      'width': 180,'elementHandlers': elementHandler
    });

doc.output("dataurlnewwindow");