Skip to content

How to convert HTML to PDF in n8n

To convert HTML to PDF in n8n, send the HTML or the URL of a public web page to the 1001fx function html2pdf. It prints the page with Chromium like a browser, with CSS, web fonts and images, and returns the PDF file to the next node.

Step by step

  1. 1

    Get your API key

    Create a free 1001fx account and copy your API key from the app.

  2. 2

    Start the workflow

    Start with the node that delivers the content, for example a Webhook node that receives an order, followed by an Edit Fields (Set) node that builds the HTML of your offer or invoice.

  3. 3

    Add the HTTP Request node

    Add the HTTP Request node and send a POST request to https://api.1001fx.com/files/html2pdf with the header X-API-KEY and your API key.

  4. 4

    Fill the fields

    html
    – The HTML from the previous node. Leave url empty.
    url
    – Alternatively the address of a public web page to print. Fill either html or url.
    format
    – Paper format: A3, A4 (default), A5, Letter, Legal or Tabloid.
    landscape
    – true for landscape pages, false (default) for portrait.
  5. 5

    Use the result

    The node returns the PDF as a file. Pass it on, for example to a Google Drive node to upload it or to a Send Email node as an attachment.

How to set up the HTTP Request node: 1001fx for n8n.

html2pdf costs 5 credits per call. All parameters and examples: html2pdf reference.

Tips

  • Put the CSS into the HTML itself. Images, style sheets and web fonts only load if their URLs are public.
  • Set margin to a CSS length such as 10mm or 0 to control the white border around the page.
  • Check your API key first with playground/hello, which does not charge credits.

Frequently asked questions

Can I convert a web page by its URL instead of HTML?
Yes. Fill url with the address of a public web page and leave html empty. Pages behind a login cannot be printed.
Which paper formats are supported?
A3, A4, A5, Letter, Legal and Tabloid, in portrait or landscape. Without a format the PDF is A4 with 1cm margins.