Actions2
Overview
This node processes PDF form files contained in binary data. It supports two main operations:
- Extract Fields: Reads a PDF form 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 user-provided field-value pairs and fills the corresponding fields in the PDF form, producing a new PDF with those fields populated.
Common scenarios include automating form processing workflows where PDFs need to be read to identify fields or pre-filled with data dynamically, such as generating filled contracts, applications, or reports.
Properties
Name | Meaning |
---|---|
Operation | Choose between "Extract Fields" (to get form field info) or "Map Fields" (to fill form fields). |
Binary Property | The name of the binary property on the input item that contains the PDF file (default: "data"). |
Output Filename | (Only for Map Fields) Optional filename for the output PDF. If empty, input filename is used. |
Fields | (Only for Map Fields) A collection of field mappings, each specifying: |
- Field Name: The exact name of the PDF form field to fill. | |
- Value: The value to set for that field. |
Output
For Extract Fields operation:
json
contains:totalFields
: Number of form fields found.fields
: Array of objects describing each field with:index
: Position number starting at 1.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'sname
and thevalue
set.
binary
: Contains the updated PDF file with mapped fields under the same binary property name as input, including metadata:data
: Base64 encoded PDF content.mimeType
: Always"application/pdf"
.fileName
: Output filename if specified.fileExtension
:"pdf"
.fileSize
: Size of the PDF in bytes as string.
Dependencies
- Requires the
pdf-lib
library to parse and manipulate PDF forms. - Input items must contain binary data with the PDF file under the specified binary property.
- No external API keys or services are required.
- The node expects valid PDF form files; non-PDF or corrupted files will cause errors.
Troubleshooting
No binary data exists on item!
Occurs if the input item lacks any binary data. Ensure the previous node outputs binary data containing the PDF.No binary data property "[name]" exists on item!
The specified binary property name does not exist on the input item. Verify the property name matches exactly.Error setting field [fieldName]:
May happen if trying to set a value on a field type that does not support it or if the field name is incorrect. Double-check field names using the Extract Fields operation first.If the node fails but "Continue On Fail" is enabled, it outputs an error message in the JSON part of the output for that item instead of stopping execution.
Links and References
- pdf-lib GitHub repository – Library used for PDF manipulation.
- n8n Documentation on Binary Data – Understanding how binary data is handled in n8n nodes.