Overview
This node generates a report document by filling a DOCX template with JSON data. It is useful when you want to automate the creation of customized reports, letters, invoices, or any document based on a predefined Word template and dynamic data.
Typical use cases include:
- Generating personalized reports from structured data.
- Creating contracts or agreements by merging client data into templates.
- Automating invoice generation with customer and transaction details.
- Producing certificates or badges with user-specific information.
The node supports optionally converting the generated DOCX report into a PDF file for easier sharing or printing.
Properties
| Name | Meaning |
|---|---|
| Template Key | The binary key name where the DOCX template file is stored in the input item. Supports deep keys using dot-notation (e.g., "level1.level2.key"). |
| Output Key | The binary key name where the generated report will be saved in the output item. Supports deep keys using dot-notation. |
| Input Data | A string containing JSON data used to fill the template placeholders. You should stringify your data before passing it here (e.g., JSON.stringify(data)). |
| Output File Name | The base file name (without extension) for the generated report file. |
| Convert to PDF | Boolean flag indicating whether to convert the generated DOCX report to PDF format (true) or keep it as DOCX (false). |
Output
The node outputs items with the following structure:
json: An empty object{}(no JSON data output).binary: Contains one key as specified by the Output Key property. This key holds the generated report file as binary data.- If Convert to PDF is false, the binary data is a DOCX file named
${Output File Name}.docx. - If Convert to PDF is true, the binary data is a PDF file named
${Output File Name}.pdf.
- If Convert to PDF is false, the binary data is a DOCX file named
Dependencies
- Requires a valid DOCX template file provided as binary data in the input item under the specified Template Key.
- Uses the
easy-template-xlibrary to process DOCX templates with JSON data. - Uses the
libreoffice-convertlibrary to convert DOCX files to PDF if requested. - No external API keys or services are required.
- The node depends on having LibreOffice installed on the system for the DOCX to PDF conversion to work.
Troubleshooting
Error parsing template data:
Occurs if the Input Data string is not valid JSON. Ensure you pass properly stringified JSON data.No binary data exists on item!
Happens if the input item does not contain the binary template file under the specified Template Key. Verify that the input contains the correct binary data.Something went wrong creating the report:
Could indicate issues with the template processing or file conversion. Check that the DOCX template is valid and that LibreOffice is correctly installed if converting to PDF.PDF conversion errors:
If PDF conversion fails, ensure LibreOffice is installed and accessible by the environment running n8n.
Links and References
- easy-template-x GitHub – Template engine used for DOCX processing.
- LibreOffice – Required for DOCX to PDF conversion.
- n8n Documentation: Working with Binary Data