peterdemartini / html5-to-pdf

HTML to PDF converter based on markdown-to-pdf
http://peterdemartini.github.io/html5-to-pdf/
MIT License
119 stars 29 forks source link

Parallel generation - are multiple .start()'s needed? #52

Open actuallymentor opened 4 years ago

actuallymentor commented 4 years ago

Thanks for this wonderful package!

I'm generating two pdfs in the following approximate manner:

const pdfWithCover = new pdf( {...} )
const pdfWithoutCover = new pdf( {...} )

await pdfWithCover.start()
await pdfWithoutCover.start()

await Promise.all( [
    pdfWithCover.build(),
    pdfWithoutCover.build()
] )

await pdfWithCover.close()
await pdfWithoutCover.close()

Does this introduce overhead by calling two .start()'s or is that inconsequential? Is there a resource-optimal way to do this as scale? (e.g. generating 100 pdfs).

Thank you!

peterdemartini commented 4 years ago

Multiple starts are needed for this. But it might make sense to have a reusable puppeteer instance, which will require a change to the library.