JSPDF is the HTML5 client-side solution for generating PDFs. This is perfect for event tickets, reports, and certificates. Just include the JSPDF library in your <head>, generate your PDF using the many built-in functions.
You can use pdf from html as follows,
STEP 1. Download the Files From Github.
STEP 2. Add the Following Files in the Header
<em><span style="font-size:small;"><script type="text/javascript" src="jquery/jquery-1.7.1.min.js"></script> </span></em> <em><span style="font-size: small;"><script type="text/javascript" src="jspdf.js"></script> </span></em> <em><span style="font-size: small;"><script type="text/javascript" src="jspdf.plugin.standard_fonts_metrics.js"></script> </span></em> <em><span style="font-size: small;"><script type="text/javascript" src="jspdf.plugin.split_text_to_size.js"></script> </span></em> <em><span style="font-size: small;"><script type="text/javascript" src="jspdf.plugin.from_html.js"></script>
or just use link below:
<script src=”//mrrio.github.io/jsPDF/dist/jspdf.debug.js”></script>
STEP 3. Add JSPDF from HTML SCRIPT
<script> function demoFromHTML() { var doc = new jsPDF('p', 'in', 'letter'); var source = $('#testcase').first(); var specialElementHandlers = { '#bypassme': function(element, renderer) { return true; } }; doc.fromHTML( source, // HTML string or DOM elem ref. 0.5, // x coord 0.5, // y coord { 'width': 7.5, // max width of content on PDF 'elementHandlers': specialElementHandlers }); doc.output('dataurl'); } </script>
STEP 4. Add Your Body Content
<a href="javascript:demoFromHTML()" class="button"> <div id="testcase"> <h1> We support special element handlers. Register them with jQuery-style. </h1> </div>
Browser Compatibility:
jsPDF will work in IE6+*, Firefox 3+, Chrome, Safari 3+, Opera. For IE9 and below.
Whats the diference between, step 3 and step 5? Seems quite the same to me…
good question !
i even wonder
Make sure you wrap your script tags with font-size, people!
what is the meaning of this
or just use link below:
I got this error:end3.html?_ijt=emim25bojm94mk740fq0sng274:1 Not allowed to navigate top frame to data URL: data:application/pdf;base64,JVBE… etc
Updating the Content with above changes.
How To Export HTML and Tag Data Into Pdf?
Ask