eKoopmans/html2pdf.js

Multiple Page download found slowness while downloading

Srikantsurya opened this issue · 0 comments

Hi,

If there are more than 100 page which consists of images, link and more styles, we getting time out issue in browser and completely that browser get hanged, using version of html2pdf 0.9.2, as html2pdf.bundle.js which we can make use of to get faster downloading of pdf.

Making use of this conversion of code:

const downloadPDF = (elements, options) => {
let worker = html2pdf()
.set(options)
.from(elements[0])

if (elements.length > 1) {
    worker = worker.toPdf() // worker is now a jsPDF instance

    // add each element/page individually to the PDF render process
    elements.slice(1).forEach((element, index) => {

        worker = worker
            .get('pdf')
            .then(pdf => {
                pdf.addPage()
            })
            .from(element)
            .toContainer()
            .toCanvas()
            .toPdf()                  
    })
}