我有一個ID爲「div1」的div,我需要將它轉換爲pdf .so我試圖在JSP中使用angular 2.JSpdf工作良好,當我試圖做doc.autoTable(COL,行);.但是當我想導出做PDF它不工作如何在Angular 2中將所有div內容導出爲pdf格式
<div class="container" id="div1">
<table>
<tr>
<th>Company</th>
<th>Contact</th>
<th>Country</th>
</tr>
<tr>
<td>Alfreds Futterkiste</td>
<td>Maria Anders</td>
<td>Germany</td>
</tr>
<tr>
<td>Centro comercial Moctezuma</td>
<td>Francisco Chang</td>
<td>Mexico</td>
</tr>
</table>
<button id="create" (click)="convert()">Create file</button>
</div>
convert(){
const elementToPrint = document.getElementById('div1');
console.log('eelementToPrint',elementToPrint); //The html element to become a pdf
const pdf = new jsPDF('p', 'pt', 'a4');
pdf.addHTML(elementToPrint,() => {
doc.save('web.pdf');
});
}
是否有任何其他方式導出PDF在角2與圖像和css –
https://stackoverflow.com/a/43064789/7751910 https://stackoverflow.com/a/23517501/7751910 https:// stackoverflow.com的.com /一個/7751910分之28335753 –