Currently, I use html2pdf.js to generate PDFs using HTML, but I need a little more customisation. How can I create the same setup using jsPDF and, if necessary, html2canvas?
The following is my current setup:
async function downloadPDF() {
const element = document.getElementById("report");
const options = {
image: { type: "jpeg", quality: 0.95 },
html2canvas: { scale: 3 },
jsPDF: {
format: "a4",
orientation: "portrait",
},
margin: [12, 0],
pagebreak: { avoid: ".section", mode: "css" },
};
const fileName = "test_123"
await html2pdf()
.from(element)
.set(options)
.save(`${fileName}.pdf`);
}