JSFiddle - React, Tailwind, and code Playground
by godhong
HTML
<script src="https://raw.github.com/MrRio/jsPDF/master/examples/js/jquery/jquery-ui-1.8.17.custom.min.js"></script>
<script src="https://raw.github.com/MrRio/jsPDF/master/jspdf.js"></script>
<script src="https://raw.github.com/eligrey/FileSaver.js/master/FileSaver.js"></script>
<script src="https://raw.github.com/eligrey/Blob.js/master/BlobBuilder.js"></script>
<script src="https://raw.github.com/MrRio/jsPDF/master/jspdf.plugin.addimage.js"></script>
<script src="https://raw.github.com/MrRio/jsPDF/master/jspdf.plugin.from_html.js"></script>
<script src="http://jspdf.com/jspdf.plugin.ie_below_9_shim.js"></script>
<script src="http://jspdf.com/jspdf.plugin.sillysvgrenderer.js"></script>
<script src="http://jspdf.com/jspdf.plugin.split_text_to_size.js"></script>
<script src="http://jspdf.com/jspdf.plugin.standard_fonts_metrics.js"></script>
<div class="span12">
<h2>The Basics</h2>
<p>Simply include the jsPDF library in your <span class="source"><head></span>, generate your PDF using the <i>many</i> built-in functions, then hook up a button to trigger the download. All the examples here use jQuery.</p>
<h2>Browser Compatibility</h2>
<p>jsPDF will work in IE6+*, Firefox 3+, Chrome, Safari 3+, Opera. For IE9 and below, we lazily load a Flash shim called Downloadify which enables the files to be downloaded.</p>
<p>* Current build does not have IE6-9 shim enabled</p>
<h2>Need Help?</h2>
</div>
JavaScript
var jq_html = $("div.span12").html();
var doc = new jsPDF();
// We'll make our own renderer to skip this editor
var specialElementHandlers = {
'#editor': function (element, renderer) {
return true;
}
};
// All units are in the set measurement for the document
// This can be changed to "pt" (points), "mm" (Default), "cm", "in"
doc.fromHTML(jq_html, 15, 15, {
'width': 170,
'elementHandlers': specialElementHandlers
});
doc.save('Test.pdf');