2016-11-20 48 views
1

我试图用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>

+0

想知道如果你解决了这个问题。 – TheNastyOne

回答