Reputation: 4668
Using jsPDF, currently attempting to do the following:
Define downloadPDF function
Declare a button with an onclick that calls downloadPDF()
<html>
<head>
<title>Page Title</title>
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="//mrrio.github.io/jsPDF/dist/jspdf.debug.js"></script>
</head>
<body>
<script>
function downloadPDF() {
var doc = new jsPDF('p', 'in', 'letter');
doc.text('Hello world', 10, 10);
doc.save('myPDF');
}
</script>
<button onclick="downloadPDF()" class="button">Run Code</button>
</body>
</html>
But the PDF document turns out to be empty.
Any ideas ?
Upvotes: 0
Views: 1869
Reputation: 689
What are the arguments that you're passing to the jsPDF constructor supposed to do? Removing them worked for me:
var doc = new jsPDF();
Working example: http://output.jsbin.com/kaxafuwiri
Upvotes: 2