jsPDF downloading blank pdf
jspdf
Solution
The second argument in the addHTML function is a callback function which gets called after the HTML is rendered.
pdf.addHTML(document.body, function() {
pdf.save('*.pdf');
});
Problem
I'm using jsPDF to generate a pdf from the current HTML, the code works fine if I paste it on the console and downloads a PDF with the current HTML, but when I put it on a JS file it downloads a blank PDF: This is the code: ``` <script> function descargar_pdf(){ var pdf = new jsPDF(); pdf.addHTML(document.body,function() {}); pdf.save('Estadodecuenta.pdf'); }; </script> ``` The function is called from a button: ``` <button class="descargar_pdf" id="ignorePDF" onclick="descargar_pdf();"> Descarga tu estado de cuenta</button> ```