So I've been working on trying to convert an HTML file produced to a PDF. I have been looking at JSPDF and come up with the following code but when I hit submit nothing happens, I can see no error in my browser debug.
<!DOCTYPE html> <html lang="en"><head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.2.61/jspdf.min.js"></script>
<script>
var doc = new jsPDF();
var specialElementHandlers = {
'#editor': function (element, renderer) {
return true;
}
};
$('#submit').click(function () {
doc.fromHTML($('#content').html(), 15, 15, {
'width': 522,
'elementHandlers': specialElementHandlers
});
doc.save('Logbook Summary.pdf');
});
</script>
<div id="content">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><title>Logbook Summary</title>
</head>
Test text here
</div> <div id="page"></div>
<button id="submit">Export to PDF</button>
</html>
Any help would be appreciated, I am sure I am missing something simple here.