Any recommendations for robust HTML to PDF conversion (handling complex CSS/Images)?

I am building a workflow where I generate dynamic HTML templates (for invoices/reports) populated with JSON data. I have the HTML generation part working perfectly.However, I am hitting a bottleneck when trying to convert this HTML into a PDF. I am struggling to get the PDF to look exactly like the HTML—specifically, my complex CSS layouts and external images aren’t rendering correctly (styles get stripped or look different than in the browser).What I am looking for: I need a solution that is:

  1. Robust & Scalable: Capable of processing high-quality documents without timeouts.

  2. Accurate: Can handle complex CSS and images so the PDF looks just like the HTML.

  3. Integrated: Preferably something available directly in n8n so I don’t have to manage complex API calls manually.

My Goal is to pass my already populated HTML string to a node and get a professional-looking PDF back. Has anyone found a specific integration or node that handles this better than the basic methods?

I always had good experiences with StirlingPDF, but I don’t know if it will process your html well. You can try it on their side before thinking about selfhosting and integrating it with n8n. The API is well documented, but unfortunately there is no official n8n node for it. So you would need to go with the HTTP Node.

https://docs.stirlingpdf.com/Functionality/Convert/

1 Like

Hi @Michal_Liska ,
This is a perfect use case for the official PDF Generator API node, which is available directly in n8n.

It has a dedicated action called HTML to PDF designed for this exact challenge. You can simply take your populated HTML template (which you’ve already generated) and pass it to this action (node), and it will handle the conversion for you.

It’s a robust, scalable solution that is great at processing complex HTML/CSS, including images and visual layouts, ensuring your generated PDF looks just like your HTML.

Given your three specific requirements—especially the need for a native n8n integration—you should definitely check out PDF Generator API.

2 Likes

thank you!

thank you Marian!

There’s an official node called ‘HTML to PDF’ by PDFMunk, exactly fits your needs

1 Like

As suggested you can run on a docker image stirlingpdf or bentopdf. For production, there was some discussion the stirling was sending telemetry data outside. therefore, i started switching it to bentopdf GitHub - alam00000/bentopdf: A Privacy First PDF Toolkit

1 Like

This is the best open source API PDF generator. I use it constantly and generate PDF files from word documents and html pages.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.