使用jsPDF和html2canvas与ES6
我试图用jsPDF和html2canvas与ES6。
我导入html2canvas和jsPDF但对addHTML得到一个错误,当我注释掉生成PDF格式的addHTML。
任何线索是什么问题?
谢谢。
jspdf.debug.js:3754Uncaught错误:您需要用://github/cburgmer/rasterizeHTML.js(...)jsPDFAPI.addHTML @ jspdf.debug.js:@ index.js 3754(匿名函数):@ bundle.js 12(匿名函数)V1。 27.2:31546(匿名函数)@ bundle.js V1.27.2:31547__webpack_require__ @引导f7845b2 ...:555fn @引导f7845b2 ...:86(匿名函数)@引导f7845b2 ...:578__webpack_require__ @引导f7845b2 ...:555(匿名函数)@引导f7845b2 ...:578(匿名函数)@引导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>
回答如下:
从https://github/MrRio/jsPDF/issues/1225:
jsPDF要求html2canvas是窗口:
window.html2canvas = html2canvas
使用jsPDF和html2canvas与ES6
我试图用jsPDF和html2canvas与ES6。
我导入html2canvas和jsPDF但对addHTML得到一个错误,当我注释掉生成PDF格式的addHTML。
任何线索是什么问题?
谢谢。
jspdf.debug.js:3754Uncaught错误:您需要用://github/cburgmer/rasterizeHTML.js(...)jsPDFAPI.addHTML @ jspdf.debug.js:@ index.js 3754(匿名函数):@ bundle.js 12(匿名函数)V1。 27.2:31546(匿名函数)@ bundle.js V1.27.2:31547__webpack_require__ @引导f7845b2 ...:555fn @引导f7845b2 ...:86(匿名函数)@引导f7845b2 ...:578__webpack_require__ @引导f7845b2 ...:555(匿名函数)@引导f7845b2 ...:578(匿名函数)@引导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>
回答如下:
从https://github/MrRio/jsPDF/issues/1225:
jsPDF要求html2canvas是窗口:
window.html2canvas = html2canvas
与本文相关的文章
评论列表 (0)
- 暂无评论