Overview
The Generate Report node creates a report document by merging a DocX template (provided as binary data) with user-supplied JSON data. Optionally, it can convert the generated document to PDF format. This node is useful for automating the creation of personalized reports, invoices, certificates, or any documents that require dynamic content insertion into templates.
Practical examples:
- Generating personalized invoices for each customer from a template and their order data.
- Creating certificates for event participants using a certificate template and participant details.
- Producing custom contracts or letters by merging client information into a standard document.
Properties
| Display Name | Type | Description |
|---|---|---|
| Template Key | String | The name of the binary key to get the template from. Supports dot-notation for deep keys (e.g., level1.level2.currentKey). |
| Output Key | String | The name of the binary key to store the generated report. Supports dot-notation for deep keys (e.g., level1.level2.newKey). |
| Input Data | String | Data used to fill the report. Should be a stringified JSON object (use JSON.stringify(data) if needed). |
| Output File Name | String | The base file name for the output document (without extension). |
| Convert to PDF | Boolean | Whether to convert the output file to PDF format (true for PDF, false for DOCX). |
Output
- The node outputs an item with a
binaryproperty containing the generated document. - The key under
binaryis determined by the Output Key property. - The value is a binary file:
- If Convert to PDF is enabled, the file will be in PDF format and named
[Output File Name].pdf. - Otherwise, the file will be in DOCX format and named
[Output File Name].docx.
- If Convert to PDF is enabled, the file will be in PDF format and named
- The
jsonproperty is present but empty.
Example output structure:
{
"json": {},
"binary": {
"report": {
"data": "<binary data>",
"fileName": "Report.pdf",
"mimeType": "application/pdf"
}
}
}
(The actual key under binary depends on your Output Key setting.)
Dependencies
- DocX Template: You must provide a valid DocX template as binary input under the specified Template Key.
- External Libraries: Uses
easy-template-xfor template processing andlibreoffice-convertfor PDF conversion. - LibreOffice: PDF conversion requires LibreOffice to be installed and accessible on the host system.
- n8n Configuration: No special environment variables are required, but the node expects binary data to be present on the input item.
Troubleshooting
Common issues:
- "No binary data exists on item!"
The input item does not contain binary data under the specified Template Key. Ensure you have uploaded or passed a DocX template correctly. - "Something went wrong while parsing the template data."
The Input Data is not valid JSON. Make sure you useJSON.stringify()when passing objects. - "Something went wrong creating the report."
There was an error during template processing or PDF conversion. Possible causes include:- Malformed template (invalid placeholders).
- Missing or incorrect data fields in Input Data.
- Issues with LibreOffice installation (for PDF conversion).
How to resolve:
- Double-check the Template Key and ensure the binary data exists.
- Validate your Input Data is a properly stringified JSON object.
- If converting to PDF, verify that LibreOffice is installed and accessible.