Reputation: 11
I am trying to download a div into PDF using jsPDF with this code:
<html>
<head>
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script src="jspdf.min.js"></script>
</head>
<body>
<div id="content">
<h3>Page to print</h3>
</div>
<button id="cmd">generate PDF</button>
</body>
</html>
<script>
$( document ).ready(function() {
$('#cmd').click(function () {
var doc = new jsPDF();
doc.addHTML($('#content')[0], 15, 15, {
'background': '#FFFFFF',
}, function() {
doc.save('sample-file.pdf');
});
});
});
</script>
When i click on the button nothing is happening, can you help me?
Upvotes: 0
Views: 2177
Reputation: 1039
Try to add it in the head
<script src="https://javascriptbase64.googlecode.com/files/base64.js"></script>
<script src="https://sprintf.googlecode.com/files/sprintf-0.7-beta1.js"></script>
Upvotes: 1