Overview
The "Write PDF Form data" node writes structured JSON data into a PDF form template and outputs the filled PDF as a binary file. This is useful for automating document generation workflows, such as creating filled contracts, invoices, or application forms based on dynamic input data.
Practical examples:
- Automatically generating filled-out tax forms from CRM data.
- Creating personalized certificates by merging user data into a PDF template.
- Populating government or HR forms with employee information.
Properties
| Name | Type | Meaning |
|---|---|---|
| PDF Filename | String | Name of the source PDF form template to write the data to (e.g., form.pdf). |
| Output File | String | Name of the output PDF file that will contain the filled-in data (e.g., report.pdf). |
| JSON Property Name | String | Name of the property in the input JSON where the data to fill into the PDF is located. |
Output
- json: The original input JSON data is preserved in the output.
- binary: Contains the generated PDF file under the key specified by the "Output File" property. This is the filled PDF form as binary data, ready for download or further processing.
Dependencies
- Requires access to the specified PDF template file (
PDF Filename) on the server where n8n is running. - Relies on the
fs/promisesmodule for file operations. - Uses a helper function (
fillForm) from a local dependency to perform the actual PDF filling.
Troubleshooting
Common issues:
File not found:
- Error:
The file "<PDF Filename>" could not be found.- Cause: The specified PDF template does not exist at the given path.
- Solution: Ensure the file exists and the path is correct relative to the n8n process.
- Error:
Incorrect JSON structure:
- Error:
The json data has the wrong structure (name/type/value).- Cause: The data provided in the JSON property does not have the expected fields (
type,name,value). - Solution: Make sure your data array contains objects with these keys.
- Cause: The data provided in the JSON property does not have the expected fields (
- Error:
PDF generation failure:
- Error:
The report pdf could not be generated.- Cause: An error occurred during the PDF filling process.
- Solution: Check the validity of the PDF template and the input data.
- Error:
Links and References
- n8n Documentation: Custom Nodes
- Node.js fs/promises documentation
- PDF Form Filling Concepts (general background)