DocxTemplater icon

DocxTemplater

Generate an Office document from a template

Render

AI-generated

Overview

This node renders a DOCX template into a document using provided context data. It is useful for generating customized Office documents such as reports, contracts, or letters by filling placeholders in a DOCX template with dynamic data. For example, it can be used to create personalized invoices by merging customer data into a predefined invoice template.

Use Case Examples

  1. Generating a personalized contract by merging client details into a DOCX template.
  2. Creating a report document by filling in data from a database into a DOCX template.

Properties

Name Meaning
Input File Name The name of the binary input field containing the DOCX template file to be rendered.
Data The JSON object containing the context data to fill into the DOCX template placeholders.
Options.Extra Modules Additional Docxtemplater modules to load for extended functionality. These modules must be installed in the n8n environment.
Options.File Name The name of the output rendered DOCX file.
Options.Paragraph Loop Whether to remove additional spaces caused by loop tags in the template.
Options.Put Output File in Field The name of the binary output field to store the rendered document.
Options.Render Newlines Whether newline characters in tags should be rendered as line breaks in the output.

Output

Binary

The rendered DOCX document is output as binary data in the specified output binary field.

JSON

binary - The binary data of the rendered DOCX document.

Dependencies

  • Requires the 'docxtemplater' and 'pizzip' libraries for DOCX template processing.
  • Supports loading additional Docxtemplater modules which must be installed in the n8n environment.

Troubleshooting

  • Common errors include template syntax errors or missing placeholders in the DOCX template, which will throw detailed TemplateError messages.
  • If the node fails due to module loading issues, ensure the specified extra modules are installed in the n8n environment.
  • Errors during rendering may include JSON parsing issues in custom filters or data resolvers; verify the input context data format.

Links

Discussion