Convert HTML to PDF

Issue Description:

I am currently facing a challenge in converting an HTML template to a PDF and could use some guidance from the community.

Details:

  • HTML Template:
    My HTML template is a PDF of a proposal. I got the data from my PostgresDB and populated it in the HTML template. HTML generate is perfect.

Challenge:

I am looking for the most suitable solution to convert my HTML template to a PDF format. Despite exploring different options, I haven’t found a solution that meets my requirements.

Request:

I would appreciate any suggestions, recommendations, or insights from the community on effective methods or tools for converting HTML to PDF.

Thank you in advance for your assistance! Your insights are highly valued.

2 Likes

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:
2 Likes

I am using n8n cloud. The database I am using is Podtgres that his hosted by Supabase.

@rafay_javed , you can utilize APITemplate.io - HTML to PDF service with APITemplate.io node.

3 Likes

@rafay_javed You can try this nicely explained by our community member method here https://www.youtube.com/watch?v=bo15xdjXf1Y as well.

8 Likes

You can even try PDFMunk’s HTML to PDF Note: HTML to PDF integrations | Workflow automation with n8n

Super seamless - without having to deal with HTTP Nodes or API requests.

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, 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.

For more information check out PDF Generator API integration

2 Likes

If you need an easy solution to convert your HTML template into a clean, ready-to-share PDF, the BitRecover HTML Converter is a great fit for you. It is designed specifically to take any HTML file and convert it directly into PDF format without breaking layout, styling, or embedded content. I will recommend you try this tool once, as it also provides a free trial to its users.

this is the solution that can be used for generating PDF’s
it allows currently 1000/month PDF with free tier

Thank you for these informations

OK a few options.

Firstly, you can convert using open-source solutions like wkhtmltopdf [1] or Puppeter/Playwright [2, 3]. These all use browser rendering engines and effectively “hit print”.

You can also use commercial APIs that will run this software for you. There are tons of SaaS services doing this, they’re all pretty much the same. Some of them have GUIs for editing the HTML.

The problem with using a HTML approach for something important is that (1) they’ll look a bit rubbish (i.e. like they’ve been printed from Chrome) and [2] HTML isn’t really built for this, so you’re at risk of things breaking when you generate PDFs. For example, a table may go off the page, or table columns might not have the right widths and look weird, or you’ll get orphans or widows on pagination, or the table of contents might not work correctly.

For that reason I’d recommend re-building your template. If you want something cheap, use an open source tool like pdfmake [4] (TypeScript/JS) or reportlab [5] (python) or use LaTeX [6] if it’s very technical. These might give you “good enough” solutions. They’re ok. Might be good enough for internal use at a company, for example.

Finally if you’re building a commercial app and it needs to look polished, use a commercial product. If you’re quite serious and want something powerful, checkout Papermill [7] (disclaimer: our product) that has its own design language and API. Report lab has a commercial service too. Easy to integrate but will take some skill or money to use. Or use a professional SDK like Apryse [8] and build your own, same caveats apply.

I coincidentally wrote a relevant blog article earlier this week [9].

David

[1] https://wkhtmltopdf.org/

[2] https://pptr.dev/

[3] https://playwright.dev/

[4] https://pdfmake.org/#/

[5] reportlab · PyPI

[6] https://www.latex-project.org/

[7] https://papermill.io

[8] https://apryse.com/

[7] Papermill

yeah this is a pretty common issue :sweat_smile: HTML looks perfect but PDF breaks

there’s also a ready template/workflow which makes it easier to plug into your existing flow