I have this code, but doesn't work. The console return me this error:
Cannot read property 'widths' of undefined - jspdf.plugin.from_html.js:169
Someone could help me?
<div id="box">
Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi...
</div>
<button id="pdf_new"> New PDF</button>
<!-- Analytics -->
<script type="text/javascript">
var doc = new jsPDF();
var specialElementHandlers = {
'#editor': function (element, renderer) {
return true;
}
};
$('#pdf_new').click(function(){
var html=$("#box").html();
doc.fromHTML(html,200,200, {
'width': 500,
'elementHandlers': specialElementHandlers
});
doc.save("Test.pdf");
});
</script>
Here you can find the jspdf.plugin.from_html.js , problem is at row 720 of this file
I found the problem, I didn't include all the main files of jsPDF libraries. Now it works!!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.