function downloadPDF() { const element = document.getElementById(“slip”); const opt = { margin: 0.2, filename: “Bulletin_de_paie.pdf”, image: { type: ‘jpeg’, quality: 1 }, html2canvas: { scale: 3, useCORS: true, logging: true }, jsPDF: { unit: ‘mm’, format: ‘a4’, orientation: ‘portrait’ } }; // Force a fresh re-render of the preview before export element.style.background = “#ffffff”; // important for PDF background html2pdf() .set(opt) .from(element) .toPdf() .get(‘pdf’) .then(function (pdf) { window.open(pdf.output(‘bloburl’), ‘_blank’); // open preview in new tab pdf.save(“Bulletin_de_paie.pdf”); // also auto-download }); }

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *