I want to convert div#printableArea
into a PDF. The code works and a file is downloaded successfully. When I open the file it has nothing but undefined
in it. I can't seem to find the solution. Can you guys help? Thanks.
This is the js file loaded:
<script src="form_html.js"></script>
<script src="split_text_to_size.js"></script>
<script src="standard_fonts_metrics.js"></script>
<script src="canvas.js"></script>
<script type="text/javascript" src="http://mrrio.github.io/jsPDF/dist/jspdf.debug.js"></script>
<script>
function demoFromHTML() {
var pdf = new jsPDF();
var source = $('#printableArea').first();
var specialElementHandlers = {
'#bypassme': function(element, renderer) {
return true;
}
};
margins = {
top: 80,
bottom: 60,
left: 40,
width: 522
};
pdf.fromHTML(
source.get(), // HTML string or DOM elem ref.
margins.left, // x coord
margins.top, // y coord
{
'width': margins.width, // max width of content on PDF
'elementHandlers': specialElementHandlers
},
function (dispose) {
// dispose: object with X, Y of the last line add to the PDF
// this allow the insertion of new lines after html
pdf.save('Test.pdf');
},
margins
)
}
</script>
<div id="printableArea">
<table>
<tr>
<td>
My contents...
</td>
</tr>
</table>
</div>