Doc Fill

Node made for filling a pdf form.

Overview

This node is designed to fill PDF forms by mapping keys in the PDF form to corresponding values provided in a JSON configuration. It processes input PDF documents, fills specified form fields with given data, and outputs the modified PDF. This is useful for automating the completion of PDF forms such as applications, contracts, or surveys, where data is dynamically inserted into predefined fields.

Use Case Examples

  1. Automatically fill a PDF application form with user data collected from a web form.
  2. Generate personalized contracts by filling PDF templates with client-specific information.
  3. Populate survey or feedback forms in PDF format with responses collected from other systems.

Properties

Name Meaning
Property Name Name of the binary property which holds the input PDF document to be used.
Property Name Out Name of the binary property for the output PDF document after filling the form.
Configuration JSON JSON used to map the keys in the PDF form to the corresponding values to fill in the form fields.

Output

Binary

The node outputs a filled PDF document as binary data under the specified output binary property.

JSON

  • json - The original JSON data of the input item, passed through unchanged.
    binary - The binary data of the filled PDF document, ready for further use or download.
  • pairedItem - Information to maintain pairing with the original input item for tracking and reference.

Dependencies

  • pdf-lib library for PDF manipulation
  • @pdf-lib/fontkit for font embedding
  • Node.js fs/promises and path modules for file and path handling

Troubleshooting

  • Ensure the input binary property contains a valid PDF file; otherwise, the node will throw an error indicating the wrong MIME type.
  • If fonts fail to load, check that the font files exist in the expected directory and have correct permissions.
  • Malformed or incorrect JSON configuration can cause the form filling to fail or produce unexpected results; validate the JSON before use.
  • If the node fails and 'Continue On Fail' is not enabled, it will stop execution and throw an error with item index information for easier debugging.

Discussion