Overview
This node generates PDF documents using the N8N Tools platform. It supports three main operations:
- Generate from Template: Create a PDF by populating a predefined template with JSON data.
- (Other operations exist but are out of scope for this request.)
The "Generate from Template" operation is useful when you have standardized document layouts (e.g., invoices, reports, contracts) and want to dynamically fill them with data to produce consistent PDFs automatically.
Practical example:
You maintain a Word-based invoice template on the N8N Tools platform. Using this node, you provide the template ID and JSON data containing customer details and line items. The node returns a generated PDF invoice ready for sending or archiving.
Properties
| Name | Meaning |
|---|---|
| Template | Select a predefined PDF template either from a searchable list or by entering its ID directly. |
| Template Data | JSON object containing key-value pairs used to populate variables in the selected template. |
| Options | Collection of optional settings affecting PDF output: |
| - Filename | Name of the generated PDF file (default: "document.pdf"). |
| - Format | Paper size format; options: A4, A3, Letter, Legal (default: A4). |
| - Orientation | Page orientation; options: Portrait, Landscape (default: Portrait). |
| - Include Header | Whether to include a header section in the PDF (default: false). |
| - Include Footer | Whether to include a footer section in the PDF (default: false). |
| - Margin Top | Top margin size (e.g., "1cm", "10px") (default: "1cm"). |
| - Margin Bottom | Bottom margin size (default: "1cm"). |
| - Margin Left | Left margin size (default: "1cm"). |
| - Margin Right | Right margin size (default: "1cm"). |
Output
The node outputs an array of items, each containing:
json: Metadata about the generated PDF including:
success: Boolean indicating if generation succeeded.filename: The name of the generated PDF file.size: Size of the PDF in bytes.operation: The operation performed ("generateFromTemplate").- Usage-related headers such as credits used, remaining credits, cost in USD, operation cost, and any budget alerts/messages returned by the API.
binary.data: The actual PDF file content encoded as binary data, ready for further use in workflows (e.g., saving to disk, sending via email).
Dependencies
- Requires an API key credential for the N8N Tools platform to authenticate requests.
- Uses HTTP requests to communicate with the N8N Tools API endpoints.
- Relies on the
form-datapackage internally to send template files when generating PDFs from templates.
Troubleshooting
- Missing Template ID: The node throws an error if no template ID is provided when generating from a template. Ensure the template ID is correctly set.
- Invalid JSON in Template Data: If the JSON data for populating the template is malformed, the node defaults to an empty object but users should verify JSON correctness.
- API Request Failures: Network issues or invalid API keys will cause HTTP request errors. Verify API credentials and network connectivity.
- No Response Body: If the API returns no body, the node throws an error. This may indicate server-side issues or misconfiguration.
- Unexpected Response Type: The node expects a binary buffer for the PDF. If the response type differs, it raises an error.
To resolve these issues, check input parameters, validate JSON syntax, confirm API credentials, and review API service status.
Links and References
- N8N Tools Platform Documentation (for general usage and API details)
- PDF Template Management (how to create and manage templates)
If you need details on other operations or resources, please let me know!