DocxTemplates icon

DocxTemplates

Transforms a docx file's content based on a json

Overview

This node transforms the content of a DOCX file based on a provided JSON template. It fetches a DOCX document from a specified URL, applies data from a JSON template to generate a customized DOCX report, and outputs the resulting file. This is useful for automating document generation tasks such as creating personalized reports, contracts, invoices, or letters by merging static DOCX templates with dynamic data.

Practical examples:

  • Generating personalized offer letters by filling in candidate details.
  • Creating invoices by merging billing data into a DOCX invoice template.
  • Producing custom reports where data points are dynamically inserted into a DOCX format.

Properties

Name Meaning
File URL URL path where the DOCX template file can be retrieved.
JSON Template JSON object representing the data template used to fill the DOCX document placeholders.

Output

The node outputs an array of items, each containing:

  • json: An empty JSON object (no additional metadata).
  • binary: A binary property holding the generated DOCX file:
    • The binary data represents the transformed DOCX document after applying the JSON template.
    • The output file is named "test.docx" and has the MIME type for DOCX files.

This binary output can be used downstream in workflows for saving, sending, or further processing the generated DOCX document.

Dependencies

  • Requires internet access to fetch the DOCX template file from the provided URL.
  • Uses the external library for DOCX templating to apply JSON data to the DOCX template.
  • No explicit API keys or credentials are required by the node itself, but the URL must be accessible (may require authentication depending on the source).

Troubleshooting

  • Common issues:

    • Invalid or inaccessible File URL: The node will fail if it cannot fetch the DOCX file from the given URL.
    • Malformed JSON Template: If the JSON template string is not valid JSON, parsing will fail.
    • Template-data mismatch: If the JSON template does not match placeholders in the DOCX template, the output may be incomplete or incorrect.
  • Error messages:

    • Errors related to fetching the file usually indicate network issues or invalid URLs.
    • JSON parsing errors indicate invalid JSON input in the "JSON Template" property.
    • Template processing errors may occur if the DOCX template or JSON data is incompatible; reviewing the template structure and JSON keys is recommended.
  • Resolution tips:

    • Verify the URL is correct and accessible.
    • Validate the JSON template using a JSON validator before input.
    • Ensure the JSON keys correspond exactly to placeholders defined in the DOCX template.

Links and References

Discussion