Reputation: 27
Heading:
<head>
<script src="jquery.min.js"></script>
<script src="jspdf.min.js"></script>
<script src="html2canvas.min.js"></script>
<script src="jspdf.plugin.addhtml.js"></script>
</head>
HTML:
<div id="wrapper">
<div class="red b"></div>
<div class="yellow b"></div>
<div class="blue b"></div>
<div class="green b"></div>
</div>
JavaScript:
$(".button").click(function() {
var pdf = new jsPDF('p', 'pt', 'a4');
pdf.addHTML($("#wrapper"), function () {
pdf.save();
});
});
I want to add the div #wrapper into the pdf file when I press the button to generate it. But then when I press the button and inspect element in Chrome, it always show an unloaded events in sources.
Any help would be appreciated. Thanks!
Upvotes: 1
Views: 4565
Reputation: 1
I'm trying to use just that in my code but clicking on the button that would generate the PDF does not occur at all. I wonder if it would be possible to provide the source code to power try to manipulate and implement.Thank U.
Upvotes: 0
Reputation: 2428
There are a few things to do:
$('#wrapper')[0]
pdf.save('Test.pdf');
$('#downloadPdf').on('click', function() { var pdf = new jsPDF('p', 'pt', 'a4'); pdf.addHTML($('#wrapper')[0], function() { pdf.save('Test.pdf'); }); });
You can check Demo Fiddle here
Upvotes: 2