Overview
This node, named "Doc Create Field," is designed to add interactive fields to an existing PDF document. It takes a PDF file as input and modifies it by creating form fields according to a user-defined JSON configuration. This is useful in scenarios where you need to programmatically add fillable fields such as text inputs, checkboxes, or dropdowns to PDFs for forms, surveys, contracts, or other documents that require user interaction.
Practical examples include:
- Adding signature fields to contract PDFs.
- Creating text input fields in application forms.
- Embedding checkboxes or radio buttons in survey PDFs.
Properties
| Name | Meaning |
|---|---|
| Property Name | The name of the binary property holding the input PDF document to be modified. |
| Property Name Out | The name of the binary property where the output PDF (with added fields) will be stored. |
| Configuration JSON | A JSON string defining the fields to create inside the PDF. Each field includes details like page number and field properties. |
Output
The node outputs the modified PDF document as binary data under the specified output binary property name. The output structure contains:
json: The original JSON data from the input item, unchanged.binary: Contains the updated PDF file with the newly created fields, stored under the configured output binary property name.pairedItem: Maintains pairing information from the input item.
The binary data represents a valid PDF file with the added interactive fields ready for use.
Dependencies
- Uses the
pdf-liblibrary to load, manipulate, and save PDF documents. - Relies on helper functions (
isPDFDocumentandcreateField) from a local utility module to validate input files and create fields. - Requires the input PDF to be provided as binary data within the workflow.
- No external API keys or services are needed; all processing is done locally within the node.
Troubleshooting
- Input is not a PDF: If the binary input is not a PDF file, the node throws an error indicating the expected PDF MIME type. Ensure the input binary property contains a valid PDF.
- Invalid JSON configuration: The
Configuration JSONmust be a valid JSON string describing the fields. Malformed JSON will cause parsing errors. - Page number out of range: If the configuration references a page number not present in the PDF, the field creation may fail or throw errors.
- Continue On Fail behavior: If enabled, the node will continue processing subsequent items even if one fails, appending error details to the output.
Links and References
- pdf-lib GitHub repository – Library used for PDF manipulation.
- n8n Documentation on Working with Binary Data
- General info on PDF Forms