我試圖用es6和jsPDF和html2canvas。使用jsPDF和html2canvas與es6
我正在導入html2canvas和jsPDF,但在addHTML 上發生錯誤時,我註釋掉生成pdf的addHTML。
任何線索是什麼問題?
謝謝。
jspdf.debug.js:3754Uncaught Error: You need either https://github.com/niklasvh/html2canvas or https://github.com/cburgmer/rasterizeHTML.js (…)jsPDFAPI.addHTML @ jspdf.debug.js:3754(anonymous function) @ index.js:12(anonymous function) @ bundle.js?V1.27.2:31546(anonymous function) @ bundle.js?V1.27.2:31547__webpack_require__ @ bootstrap f7845b2…:555fn @ bootstrap f7845b2…:86(anonymous function) @ bootstrap f7845b2…:578__webpack_require__ @ bootstrap f7845b2…:555(anonymous function) @ bootstrap f7845b2…:578(anonymous function) @ 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>
\t <p id="to-pdf">HTML content...</p>
</footer>
想知道如果你解決了這個問題。 – TheNastyOne