Wednesday 19 August 2015

How to make PDF using javascript

 

How to make PDF using javascript 

 

<!DOCTYPE html>
<html>
  <body>
    <p id="notprint">don't print this in pdf file</p>
    <div>
<p><font size="3" color="red">print this to pdf</font></p>
    </div>
  </body>
</html>
 
  • jspdf.js

  • jspdf.plugin.from_html.js

  • jspdf.plugin.split_text_to_size.js

  • jspdf.plugin.standard_fonts_metrics.js

this all above files for reference in head tag 



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

doc.output("dataurlnewwindow");

0 comments:

Post a Comment

 

Subscribe to our Newsletter

Contact our Support

Email us: youremail@gmail.com

Our Team Memebers