我正在使用angular2和jspdf。使用jspdf生成PDF角色2
所以首先我安裝jspdf:
npm install jspdf --save
我試着這樣做:
import * as jsPDF from 'jspdf';
var Html="<h5>ORDERDETAILS</h5><p>ORDERNUMBER</p><table align='center' cellpadding='0' cellspacing='0' width='600'><tr> <td style='border: 1px solid #CCC;padding:10px;'><img src='###SITE_LOGO###' alt='Cracker Deals' width='110px'> </td> </tr> ###ORDER_STATUS### <tr><td style='border-left:1px solid #CCC;border-right:1px solid #CCC;padding:15px;font-size:12px;'><div>Dear <strong> ###CUSTOMER_NAME### </strong></div><p>Thank You for your order. This mail has your order details <br>You can also view your Order Detials - <a href='###SITE_LINK###'>View Details</a></p><div><h3>Shipping Address</h3>###CUSTOMER_ADDRESS###</div></td></tr><tr><td bgcolor='#ffffff' style='padding: 15px;border: 1px solid #CCC;'>###CARTDETAILS###</td></tr><tr><td bgcolor='' align='center' style='border:1px solid #CCC; border-top:0;padding:10px;font-size:11px;'>CopyRights 2017 Cracker Deals</td></tr><tr><td bgcolor='#2874F0' style='height:10px;'></td></tr> </table>";
var doc = new jsPDF();
doc.addHTML(Html,() => {
doc.save('test.pdf');
doc.save('Test.pdf');
})
我收到此錯誤:
ERROR Error: You need either https://github.com/niklasvh/html2canvas or https://github.com/cburgmer/rasterizeHTML.js
我怎樣才能解決這個問題。
我需要生成PDF。
請告訴我。
的可能的複製[Angular2 - 從生成HTML使用jspdf PDF](https://stackoverflow.com/questions/43276882/angular2-generate-pdf-from-html-using-jspdf) –