In my project I don't know how to include a table in my pdf when it is generated. The version of my jsPDF is 1.2.61 with jQuery 1.12.4
This is my code:
<table id="tablePDF">
<tr><td>Value1a</td><td>Value2b</td><td>Value3c</td></tr>
<tr><td>Value1a</td><td>Value2b</td><td>Value3c</td></tr>
<tr><td>Value1a</td><td>Value2b</td><td>Value3c</td></tr>
<tr><td>Value1a</td><td>Value2b</td><td>Value3c</td></tr>
</table>
<button id="downloadPDF" onclick="generatePDF()">DOWNLOAD PDF</button>
<script>
function generatePDF() {
var doc = new jsPDF('p', 'pt', 'a4');
doc.fromHTML($('#tablePDF').html(), 20,20, {
'width':500
});
doc.save('Test.pdf');
}
</script>
The content of my div I would like to include in the pdf as a table.
Example: If I have a table in my html with 4 rows I would like all 4 to be reported. If there are 10 rows and the table goes beyond the sheet boundary then add a new page.
This I tried to do with the pdf.fromHTML function but I can't use it because it sets times new roman as default font and I want the arial as font.
How can I do to achieve this in the pdf?