【发布时间】:2019-02-02 21:29:25
【问题描述】:
我试图使用 jsPDF 和 html2canvas 从 HTML 生成 PDF。它适用于整页,但不适用于使用 getElementById() 的特定 div。控制台说
IndexSizeError: Index or size is negative or greater than the allowed amount html2canvas.js:2859
这是我的脚本
<script>
let doc = new jsPDF();
doc.addHTML(document.getElementById('content'), function() {
doc.save('html.pdf');
});
</script>
谁能帮我解决这个问题?
【问题讨论】:
-
假定 document.getElementById('content') 返回一些东西,最好从那里开始
-
它返回 [object HTMLDivElement] ,我认为这应该是正确的
标签: javascript jspdf html2canvas