[英]export html div into pdf with jspdf
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
无法读取未定义的属性“宽度”-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 在这里您可以找到jspdf.plugin.from_html.js ,问题出在该文件的第720行
I found the problem, I didn't include all the main files of jsPDF libraries. 我发现了问题,但没有包含jsPDF库的所有主要文件。 Now it works!!
现在可以了!!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.