96
rated 0 times
[
102]
[
6]
/ answers: 1 / hits: 46137
/ 8 Years ago, wed, june 15, 2016, 12:00:00
Hello Im trying to save my html page to PDF and I have this code:
<div id=content>
<h3>Hello, this is a H3 tag</h3>
<p>a pararaph</p>
</div>
<div id=editor></div>
<button id=cmd>Generate PDF</button>
<script>
var doc = new jsPDF();
var specialElementHandlers = {
'#editor': function (element, renderer) {
return true;
}
};
$('#cmd').click(function () {
doc.fromHTML($('#content').html(), 15, 15, {
'width': 170,
'elementHandlers': specialElementHandlers
});
doc.save('sample-file.pdf');
});
// This code is collected but useful, click below to jsfiddle link.
</script>
I uploaded to jsFiddle and works... but when I try it in my browser doesnt works and I get the error doc.fromHTML is not a function. I have the jQuery and jsPDF references exactly like jsFiddle.
More From » jquery