Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

cwray-tech's avatar

Generating Very Long PDF's

Do you know the best way to optimize generation of very large PDFs?

For my work we generate PDFs of tags to print for a nurseries trees. Several hundred tags are generated at a time, so this can end with a PDF with a couple hundred pages.

Using DomPDF currently, but only able to generate a PDF with around 400 tags at this point without getting a timeout.

Don't want to create a background job for this, as I'd like users to be able to click to download without having to wait too long.

Any ideas?

0 likes
7 replies
jlrdw's avatar

Probably not. Maybe chunk into a few smaller pdf's.

If filling your tank and if a motorcycle it's fast, but a SUV with a 30 gallon tank is going to be slower.

Same for some processing.

1 like
Tray2's avatar

The only way that I see, is to create a background job, so that the user can start the generation of the pdf, and then broadcasts when it's done, so the user can download it.

1 like
cwray-tech's avatar

@Tray2 Yeah I thought about that, but issue is I want immediate feedback and downloads to happen with one click. Is this doable with a job like that?

Snapey's avatar

I got so fed up with pdf driver issues, inconsistency with local and prod, wierd css and font issues, I decided to outsource pdf generation.

https://dpdf.io/

After 6 months, the service has been flawless, and reproduces my on-screen css grid layout perfectly

1 like
cwray-tech's avatar

Thank you to all of you. I'm considering using jsPdf on the frontend, as I've noticed it's way faster than doing in on the backend with dom pdf...

Please or to participate in this conversation.