HTML to PDF icon

HTML to PDF

Convert HTML string to PDF

HTML to PDF

AI-generated

Summary

Renders an HTML string to a PDF using headless Chrome (Puppeteer) and attaches the PDF as binary data on each input item.

Inputs

  • HTML Input (required) — HTML markup to render. Evaluated per item, so expressions can build it from incoming data. The page loads with waitUntil networkidle0, so external resources like images and CSS are fetched before printing.
  • Output Binary Field Name (required) — Binary property that will hold the PDF. Defaults to 'data'. The file is named document.pdf with MIME type application/pdf.
  • PDF Options — Optional collection of print settings. Format: A0–A6, Letter, Legal, Tabloid, Ledger, or Custom. Defaults to A4. Custom enables Width and Height, such as 15in or 20cm. Landscape: defaults to off. Margins: top, bottom, left and right, each defaulting to 0px when set. Print Background: defaults to on. Omit Background: defaults to off. Scale: 0.1–2, defaults to 1. Page Ranges: such as '1-5, 8'. Prefer CSS Page Size: lets CSS @page override the size options. Display Header/Footer plus Header Template and Footer Template: HTML templates that can use classes like pageNumber and totalPages.

Output shape

One output item per input item. The json is {success: true, size: }, and the PDF is in the binary property named by Output Binary Field Name. Each item is paired with its input item.

If Continue On Fail is enabled, a failed item returns json {error: message} with no binary data. Otherwise the first error stops the node. A single headless Chrome instance is launched per execution with --no-sandbox, and it is closed at the end. The node looks for Chrome via PUPPETEER_EXECUTABLE_PATH or common install paths. If none is found, it tries to run 'npx puppeteer browsers install chrome', which needs a Chrome-capable environment and may need network access. Header and footer templates only show when Display Header/Footer is on. Because the Format default is A4, the Margins collection must be set explicitly, or Chrome's default margins apply.

Examples

Example 1: Generate an invoice PDF from an HTML template filled with data from earlier nodes.

HTML Input set to an expression building the invoice HTML; Output Binary Field Name 'data'; PDF Options: Format A4, Margins 20px on all sides, Print Background on.

Example 2: Create a landscape report with page numbers in the footer.

PDF Options: Landscape on, Display Header/Footer on, Footer Template '

/
'.

Example 3: Produce a custom-size label PDF.

Format Custom with Width '100mm' and Height '50mm'; Prefer CSS Page Size off.

Links

Discussion