DEV Community

Sajjad hasan
Sajjad hasan

Posted on

Make a PDF from HTML in n8n Cloud with only a Code node (free tool + code)

n8n Cloud does not let you install PDF libraries in a Code node, and I did not want to pay for an API just to turn a small HTML invoice into a PDF. So I wrote a small generator in plain JavaScript that builds the PDF file itself.

Try it first, in your browser: https://operantsolo.com/n8n-html-to-pdf-tool/ (paste HTML, click Generate, download the PDF; nothing you paste is uploaded).

When it does what you need, copy the same code into an n8n Code node. Send it items with an html field and an optional filename, and it returns the PDF as binary property data.

What it supports: headings (h1 to h3), paragraphs, bullet and numbered lists, line breaks, preformatted text, horizontal rules and common HTML entities, on A4 pages with automatic page breaks.

What it does not do: CSS, images, tables, clickable links, inline bold or italic, or non-Latin text. If you need pixel-perfect pages, use a browser-based PDF service instead.

I tested the workflow in n8n Cloud on 26 October 2026 with a manual run. Two sample PDFs were read back with Extract From File and every expected phrase was found. I have not tested very large inputs, emoji or HTML from real email clients, so try it with your own HTML first.

The importable workflow and the code are free (MIT): https://github.com/operantsolo-com/n8n-free-workflow-templates/tree/main/html-to-pdf

If something breaks on your HTML, tell me the input and I will look at it.

Top comments (0)