Programmatic PDF generation on worker
Hi everyone,
I've been looking for some way to generate PDFs within a worker script.
Currently I use the browser rendering api to create PDFs of a page but according to the dashboard a single invocation takes 6 seconds...
There must be a better and faster way right?
I looked into the javascript PDF libraries (pdfkit, jspdf, pdf-lib, pdfme, etc.) but these are very limited in their features (I cannot even use a bold font?).
I have no experience with Rust but I'm considering this more and more as it seems the only solution?
But before I plunge myself into the deep with learning a bit of Rust, I'm curious if there are any other solutions?
Will I run into the same problems as javascript (limited features)?
Can I improve the speed of puppeteer rendering the PDF?
This function renders the pdf on the worker:
3 Replies
I'm mostly researching this problem because the compute time is really high
The next thing I'll try is just using an html string template and using
That would at least remove the request to the external web page.
Have you tried it with a durable object?
Using DOs improves performance by eliminating the time that it takes to spin up a new browser session.
Yes I'm using a DO
Does that count to the compute time? maybe that might be the reason