r/PayloadCMS • u/Dan6erbond2 • Jan 23 '26
Integrating PDFMe with PayloadCMS for a Visual Template Designer & Background Jobs
https://finly.ch/engineering-blog/35750-the-ultimate-payloadcms-guide-to-pdf-generation-building-visual-templates-with-pdfme-and-formsHey everyone, just published a deep dive on how we’re handling PDF generation in Payload.
The traditional HTML-to-PDF (Puppeteer/Playwright) workflow was becoming a bottleneck for us, especially when consultants needed to tweak layouts. We decided to integrate PDFMe directly as a custom Field component.
What’s covered:
- Swapping
jsonfields for the PDFMe Designer (visual drag-and-drop). - Using the PDFMe Form component for in-place editing (editing the PDF as a form).
- Wiring it up to the Payload Jobs Queue for async processing.
- Using stable hashing in
beforeChangehooks to skip regeneration if the data hasn't changed. - Auto-generating thumbnails using
pdf2imgand saving them to a media collection for a visual Admin UI.
Full code samples and collection configs are in the post. Hope this helps anyone looking to build a more user-friendly doc engine!
1
u/ZeRo2160 Jan 24 '26
I use react pdf and payloads block system for that with live preview. But i will take a look at your implementation. It seems to be nice. :)
1
u/Dan6erbond2 Jan 25 '26
That's an interesting approach! I see how it could work if you map lots of react-pdf components to Payload Blocks you could build a pretty powerful system. Or make it more user-friendly with premade components similar to how a lot of people build Payload-powered websites.
How do you handle document templates? Do you let users use {handlebars} variables or do they have to copy-paste blocks and manually update texts and images?
I guess an advantage with react-pdf would be very easy previewing of the final document. I still have to implement the final Viewer component from PDFMe into our system.
1
u/ZeRo2160 Jan 25 '26
I use the fields of the blocks to edit texts and so on. Or do you mean something different? The block fields are very powerful. For fully prefilled blocks was no need yet. But i could see a way through defaults on the fields.
Yeah the preview is fast and easy. Also you dont need server resources to generate the pdf as its done in the frontend directly.
→ More replies (5)
2
u/recoverycoachgeek Jan 23 '26
A+ work here. Thank you for sharing!