export page to pdf using js code example

Example 1: 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");

Example 2: pdf to image javascript

$("#download-image").on('click', function() {
	// For IE 10 & 11
	if(typeof window.navigator.msSaveBlob === 'function')
		window.navigator.msSaveBlob(new Blob( [__CANVAS.msToBlob()], {type: 'image/png'} ), 'page.png');
	else
		$(this).attr('href', __CANVAS.toDataURL()).attr('download', 'page.png');
});

Tags:

Html Example