PDF Form icon

PDF Form

Extract and map PDF form fields

Overview

This node processes PDF files containing form fields. It supports two main operations:

  • Extract Fields: Reads a PDF form from binary input and extracts all form fields, returning their names, types, and current values. This is useful for understanding the structure of a PDF form before filling it.
  • Map Fields: Takes specified field names and values to fill in the PDF form fields, then outputs the updated PDF as binary data. This operation is helpful for automating the population of PDF forms with dynamic data.

Typical use cases include automating form processing workflows such as filling out invoices, applications, or contracts stored as PDFs, or extracting form data for analysis.

Properties

Name Meaning
Operation Choose between "Extract Fields" (to read form fields) or "Map Fields" (to fill fields).
Binary Property The name of the binary property on the input item that contains the PDF file.

Note: Additional properties appear when selecting the "Map Fields" operation:

Name Meaning
Output Filename Optional filename for the output PDF. If empty, the original filename is used.
Fields Collection of field mappings where each entry specifies a PDF form field name and value to set.

Output

  • For Extract Fields operation:

    • json contains:
      • totalFields: Number of form fields found.
      • fields: Array of objects describing each field with:
        • index: Field position number.
        • name: Field name.
        • type: Field type (e.g., text field, checkbox).
        • value: Current value of the field (text, checked state, selected option, or null if unavailable).
      • fieldNames: Array of all field names.
    • binary: Passes through the original binary PDF data unchanged.
  • For Map Fields operation:

    • json contains:
      • success: Boolean indicating successful mapping.
      • totalFields: Number of fields mapped.
      • mappedFields: Array of objects with each field's name and the value set.
    • binary contains the updated PDF file with filled-in fields, including metadata:
      • data: Base64 encoded PDF content.
      • mimeType: Always "application/pdf".
      • fileName: Output filename if provided.
      • fileExtension: "pdf".
      • fileSize: Size of the PDF in bytes as string.

Dependencies

  • Uses the pdf-lib library to load, read, manipulate, and save PDF documents.
  • Requires input items to contain binary data representing the PDF file under the specified binary property.
  • No external API or service dependencies; all processing is local within the node.

Troubleshooting

  • No binary data exists on item!
    Occurs if the input item lacks any binary data. Ensure the input contains a binary property with the PDF file.

  • No binary data property "[name]" exists on item!
    Happens if the specified binary property name does not exist on the input item. Verify the correct binary property name is set.

  • Error setting field [fieldName]:
    Errors during field value assignment may occur if the field name is incorrect or the field type does not support the assigned value. Double-check field names and values.

  • If errors occur but "Continue On Fail" is enabled, the node will output an error message in the JSON part of the output for that item instead of stopping execution.

Links and References

Discussion