<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.20/pdfmake.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.20/vfs_fonts.js"></script>
<div id="test">
<table>
<tr>
<th>Header 1</th>
<th>Header 2</th>
<th>Header 3</th>
</tr>
<tr>
<td>Hello</td>
<td>I</td>
<td>am</td>
</tr>
<tr>
<td>a</td>
<td>table</td>
<td>.</td>
</tr>
</table>
<h1 style="text-align: center">
pdfmake
</h1>
<p>pdfmake does not generate pdfs from the html. Rather, it generates them directly from javascript.</p>
<p>It is very fast, but very limited, especially compared to PHP alternatives.</p>
<p>To get a pdf that looks like the page, you could use html2canvas, which generates an image that can be inserted into the pdf. I think this is a hack and not ideal</p>
</div>
<a href="javascript:generatePDF()">Dowload PDF</a>