Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple Page download found slowness while downloading #679

Open
Srikantsurya opened this issue Feb 8, 2024 · 0 comments
Open

Multiple Page download found slowness while downloading #679

Srikantsurya opened this issue Feb 8, 2024 · 0 comments

Comments

@Srikantsurya
Copy link

Srikantsurya commented Feb 8, 2024

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()                  
    })
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant