【发布时间】:2023-09-01 07:32:01
【问题描述】:
我正在尝试将 jsPDF 和 html2canvas 与 es6 一起使用。
我正在导入 html2canvas 和 jsPDF,但在 addHTML 上出现错误 当我注释掉 addHTML 时,会生成 pdf。
有什么线索吗?
谢谢。
jspdf.debug.js:3754未捕获错误:您需要 https://github.com/niklasvh/html2canvas 或 https://github.com/cburgmer/rasterizeHTML.js(...)jsPDFAPI.addHTML @ jspdf.debug.js:3754(匿名函数)@ index.js:12(匿名函数) @ bundle.js?V1.27.2:31546(匿名函数) @bundle.js?V1.27.2:31547__webpack_require__ @bootstrap f7845b2…:555fn @bootstrap f7845b2…:86(匿名函数) @bootstrap f7845b2…:578__webpack_require__ @bootstrap f7845b2… :555(匿名函数)@bootstrap f7845b2…:578(匿名函数)@bootstrap f7845b2…:578
import html2canvas from 'html2canvas';
import jsPDF from 'jspdf';
doc.setFontSize(40);
doc.text(35, 25, "Paranyan loves jsPDF");
doc.addHTML(document.footer,function() {
pdf.save('web.pdf');
});
<footer>
<p id="to-pdf">HTML content...</p>
</footer>
【问题讨论】:
-
想知道你是否解决了这个问题。
标签: javascript node.js reactjs jspdf html2canvas