Overview
This node converts HTML content into a PDF document using the Gotenberg API. It is useful when you want to generate PDFs dynamically from custom HTML, such as reports, invoices, or formatted documents that include images and styled text. The node supports advanced PDF options like page size, orientation, margins, metadata, accessibility features, and more.
Practical examples:
- Convert an HTML invoice template with embedded images into a printable PDF.
- Generate a PDF report from HTML content created on-the-fly in a workflow.
- Create accessible PDFs by enabling tagged PDF or PDF/UA options.
Properties
| Name | Meaning |
|---|---|
| HTML Content | The raw HTML markup to convert into a PDF. You can reference images and other assets by filename within this HTML. |
| Additional Files | Collection of additional files (e.g., images) referenced in the HTML. Each image requires specifying the filename as used in the HTML and the binary field containing the image data. |
| Paper Size | Standard paper sizes for the PDF output. Options: A3, A4, A5, Custom, Legal, Letter, Tabloid. |
| Paper Width | When "Custom" paper size is selected, specify the width with units (in, mm, cm, pt, px, pc). |
| Paper Height | When "Custom" paper size is selected, specify the height with units (in, mm, cm, pt, px, pc). |
| Landscape | Boolean flag to use landscape orientation instead of portrait. |
| Advanced Options | Collection of advanced PDF generation settings: |
| - Flatten PDF | Remove form fields and annotations from the resulting PDF. |
| - Generate Tagged PDF | Enable generation of tagged (accessible) PDF structure. |
| - Margins | Set top, bottom, left, and right margins with unit support. |
| - Metadata (JSON) | JSON string defining metadata to embed in the PDF (e.g., title, author). |
| - Omit Background | Hide the default white background to allow transparency. |
| - Page Ranges | Specify which pages to print (e.g., "1-5, 8, 11-13"). Empty means all pages. |
| - PDF for Universal Access | Enable PDF/UA standard for optimal accessibility. |
| - PDF/A Format | Convert PDF to PDF/A format for long-term archiving. Options: None, PDF/A-1b, PDF/A-2b, PDF/A-3b. |
| - Prefer CSS Page Size | Use page size defined by CSS in the HTML rather than specified paper size. |
| - Print Background | Whether to print background graphics. |
| - Scale | Scale factor for webpage rendering, between 0.1 and 2. |
| - Single Page | Render entire content on a single page instead of multiple pages. |
Output
The node outputs a binary PDF file representing the converted HTML content. The output includes:
jsonobject with metadata about the operation:success: boolean indicating if conversion succeeded.operation: the operation performed ("htmlToPdf").filename: the name of the generated PDF file.contentType: MIME type, typically "application/pdf".size: size of the PDF in bytes.paperSize: the paper size used for the PDF.
binarydata containing the actual PDF file under the keypdf.
If the output is a ZIP archive (not typical for HTML to PDF), it will be indicated accordingly with appropriate content type and binary key.
Dependencies
- Requires access to a Gotenberg API endpoint (base URL) configured via credentials.
- Needs an API authentication token or key configured in n8n credentials for Gotenberg.
- No other external dependencies are required.
Troubleshooting
- Common issues:
- Invalid or unreachable Gotenberg API URL or missing API credentials.
- Incorrectly referenced image filenames in HTML without corresponding binary data attached.
- Malformed HTML content causing conversion errors.
- Unsupported or invalid paper size or margin units.
- Error messages:
- Network or authentication errors indicate problems with API credentials or connectivity.
- Conversion errors may mention invalid input or unsupported options; verify HTML validity and property values.
- Resolutions:
- Ensure Gotenberg API credentials are correctly set up in n8n.
- Confirm all referenced images in HTML have matching binary inputs.
- Validate HTML content before conversion.
- Use supported units and valid values for paper size and margins.