Generate Report icon

Generate Report

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 data input. The node supports optionally converting the generated DOCX report into a PDF file.

Practical examples:

  • Generating personalized customer invoices from a template using order data.
  • Creating employee performance reports by merging HR data into a DOCX template.
  • Producing certificates or letters where user-specific information is injected dynamically.

Properties

Name Meaning
Template Key The binary key name in the input item that holds the DOCX template file. Supports deep keys via dot-notation (e.g., level1.level2.currentKey).
Output Key The binary key name where the generated report will be stored in the output item. Supports deep keys via 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 generated report stored in the binary property specified by the Output Key. The binary data contains either:

  • A DOCX file if Convert to PDF is false.
  • A PDF file if Convert to PDF is true.

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

The JSON part of the output item is empty ({}).

Dependencies

  • Requires an input item containing the DOCX template as binary data under the specified Template Key.
  • Uses the easy-template-x library to process DOCX templates with JSON data.
  • Uses libreoffice-convert to convert DOCX files to PDF if requested.
  • No external API keys or credentials are required.
  • The environment must support LibreOffice conversion (LibreOffice installed) for PDF conversion to work.

Troubleshooting

  • Error parsing template data: If the JSON string provided in Input Data is invalid or malformed, the node will throw an error. Ensure the data is valid JSON and properly stringified.
  • No binary data exists on item: This error occurs if the input item does not contain the binary template file under the specified Template Key. Verify the input data and key names.
  • Report creation errors: Issues during template processing or file conversion may occur due to corrupted templates or missing LibreOffice installation. Check the template file integrity and ensure LibreOffice is installed and accessible.
  • PDF conversion failure: If PDF conversion fails, confirm that LibreOffice is installed and the environment supports running it. Otherwise, disable PDF conversion.

Links and References

Discussion