Generate Report Modded icon

Generate Report Modded

Generate a report from a DocX Template and JSON data.

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 input data.

Typical use cases include:

  • Generating personalized reports from user data.
  • Creating invoices or contracts by merging templates with customer information.
  • Automating document generation workflows where templates are stored as binary data in previous nodes.

The node can optionally convert the generated DOCX report into a PDF file.

Properties

Name Meaning
Template Key The binary key name where the DOCX template is stored in the input item. Supports deep keys using dot-notation (e.g., level1.level2.currentKey).
Output Key The binary key name where the generated report will be saved in the output item. Supports deep keys using dot-notation (e.g., level1.level2.newKey).
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 for the generated report file, without extension.
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 is added or modified).
  • binary: Contains one binary property named as specified by the Output Key property. This binary data holds the generated report file:
    • If Convert to PDF is false, the binary data is a DOCX file.
    • If Convert to PDF is true, the binary data is a PDF file.

The filename of the binary data corresponds to the Output File Name property with the appropriate extension (.docx or .pdf).

Dependencies

  • Requires a DOCX template provided as binary data in the input item under the key specified by Template Key.
  • Uses the easy-template-x library to process DOCX templates with custom delimiters (« »).
  • Uses the libreoffice-convert library to optionally convert DOCX files to PDF.
  • No external API keys or services are required.
  • The node expects valid JSON string input for the template data.

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 binary data at the specified Template Key. Verify that the template file is correctly loaded in a previous node.

  • Something went wrong creating the report:
    Could indicate issues with template processing or file conversion. Check that the DOCX template is valid and that LibreOffice is installed and accessible for PDF conversion.

  • PDF conversion errors:
    If converting to PDF fails, ensure LibreOffice is installed on the system running n8n, as libreoffice-convert depends on it.

Links and References

Discussion