Pdf Form
What this guide covers
This guide walks you through filling a PDF AcroForm template in n8n using template.pdf and formdata.json. Data keys map directly to form field names (firstname, lastname, etc.). Output is PDF only. Use Keep PDF Editable to leave fields editable after fill, or turn it off to flatten the form.
Before You Start
template.pdf is a membership-style form with four fields. JSON keys must match the internal AcroForm name, not the visible label on screen. Names are case-sensitive.formdata.json (recommended), test.xml, or test.csv. All three supply the same four values. Pdf Form data is a single flat object, not nested like the HTML invoice sample.Generate Document (Single) with Pdf Form uses the generate template engine with a PDF form as the template. For filling any existing PDF AcroForm without the generate workflow, see Fill a PDF Form. To discover field names on an unknown PDF, run Extract Form Data From PDF on the template first.
Sample File Pack
Download all four files below. One PDF form template plus three equivalent data formats.
What's Inside the Sample Files
Form fields in template.pdf
The sample PDF is a simple membership / registration form. Each AcroForm field name maps to a key in your data:
| AcroForm field name | Typical use in template | Sample value (formdata.json) |
|---|---|---|
firstname | Given name | John |
lastname | Family name | Adams |
gender | Gender selection | Female |
member | Membership tier | Basic |
AcroForm names are often lowercase with no spaces (firstname), even when the PDF shows "First Name". If a value appears blank, the key in your JSON almost always does not match the internal field name. Use Extract Form Data From PDF to list exact names from your own template.
Field mapping across all data files
| AcroForm field | JSON key (formdata.json) | XML element (test.xml) | CSV column (test.csv) | Sample value |
|---|---|---|---|---|
firstname | firstname | firstname | firstname | John |
lastname | lastname | lastname | lastname | Adams |
gender | gender | gender | gender | Female |
member | member | member | member | Basic |
Unlike Word or HTML templates, there are no mustache placeholders. The engine matches data keys to AcroForm field names one to one.
The Workflow at a Glance
Manual Trigger → Read Binary File (template.pdf) → PDF4me Generate Document (Single) → (optional) Write Binary File
| Step | n8n node | Purpose |
|---|---|---|
| 1 | Manual Trigger | Start the workflow on demand |
| 2 | Read Binary File | Loads template.pdf into binary property data |
| 3 | PDF4me → Generate Document (Single) | Fills AcroForm fields from JSON/XML/CSV, outputs PDF |
| 4 | Write Binary File or Send Email (optional) | Saves or sends generated_document_output.pdf |
/generate-document-single-template-file-type.png)
Set Template File Type to Pdf Form. Output Type is PDF only for this template type.
Step 1: Download and Place the Sample Files
- Download
template.pdfandformdata.jsonfrom the Sample File Pack above. - Save
template.pdfsomewhere n8n can read it (local path on self-hosted, or cloud storage for production triggers). - Optionally download
test.xmlortest.csvto test other data types.
Step 2: Create the n8n Workflow
- In n8n, create a new workflow.
- Add a Manual Trigger node.
- Add a Read Binary File node after the trigger.
- Add PDF4me → Generate Document (Single) after Read Binary File.
- Connect your PDF4me credential.
Template File Input Type: HTML Code only works when Template File Type is HTML. For Pdf Form, use Binary Data, Base64 String, or URL.
Step 3: Load the PDF Template (Read Binary File)
| Field | Value |
|---|---|
| File Path | Full path to your downloaded template.pdf |
| Property Name | data (default; used as Template Binary Property in PDF4me) |
Execute this node once and confirm the output item shows binary data with filename template.pdf.
Step 4: Configure PDF4me Generate Document (Single)
Core settings
| Field | Value | Notes |
|---|---|---|
| Credential to connect with | Your PDF4me credential | Get API key |
| Resource | Generate | |
| Generate Operations | Generate Document (Single) | |
| Template File Type | Pdf Form | PDF with AcroForm fields |
| Output Type | Only option for Pdf Form |
Template input (from Read Binary File)
| Field | Value |
|---|---|
| Template File Input Type | Binary Data |
| Template Binary Property | data |
| Template File Name | template.pdf |
Document data (paste JSON from formdata.json)
| Field | Value |
|---|---|
| Document Data Input Type | Text |
| Document Data Type | JSON |
| Document Data Text | Paste the full contents of formdata.json (see block below) |
{
"firstname": "John",
"lastname": "Adams",
"gender": "Female",
"member": "Basic"
}
Output options
| Field | Value | When to use |
|---|---|---|
| Keep PDF Editable | On | Recipient should still edit fields in the filled PDF |
| Keep PDF Editable | Off (default) | Flatten form fields into static content |
| Binary Data Output Name | data (default) | Binary property for the output PDF |
Step 5: Execute and Verify the PDF
- Click Execute workflow.
- Open the PDF4me node output. Under Binary, open property
data(generated_document_output.pdf). - Confirm all four fields are filled:
- firstname → John
- lastname → Adams
- gender → Female
- member → Basic
If any field is empty, compare your JSON keys with the AcroForm names in template.pdf character by character.
Step 6: Save or Send the Output (Optional)
Write Binary File:
| Field | Value |
|---|---|
| File Name | filled-form-output.pdf |
| Data Property Name | data |
| Output Path | Target folder on your n8n host |
Send Email: attach the binary data from PDF4me as the PDF attachment.
Alternative Data Formats
Option A: JSON file as binary (formdata.json)
- Add Read Binary File for
formdata.json(use a Merge node if template and data share the workflow item). - Set Document Data Input Type to Binary Data, Document Data Type to JSON, Document Binary Property to your data field, Document Data File Name to
formdata.json.
If both template and data use property data, one overwrites the other. Use separate names (e.g. template and formData) or merge items from two Read Binary File nodes.
Option B: XML (test.xml)
Set Document Data Type to XML and paste:
<?xml version="1.0" encoding="UTF-8"?>
<Person>
<firstname>John</firstname>
<lastname>Adams</lastname>
<gender>Female</gender>
<member>Basic</member>
</Person>
Element names match the AcroForm field names and JSON keys.
Option C: CSV (test.csv)
Set Document Data Type to CSV and paste (header row + one data row):
firstname,lastname,gender,member
"John","Adams","Female","Basic"
Column headers match the AcroForm field names directly.
Alternative Template Input: URL
Host template.pdf at a public HTTPS URL, then set:
| Field | Value |
|---|---|
| Template File Input Type | URL |
| Template File URL | Public link to template.pdf |
| Template File Name | template.pdf |
No Read Binary File node is required. Data can still be pasted as Document Data Text or loaded from a URL.
Production Workflow Patterns
Common ways to fill PDF forms in productionOnce the sample test works, replace the Manual Trigger with these patterns.
- Webhook receives registration payload.
- Map body fields to JSON keys matching AcroForm names.
- PDF4me fills fixed
template.pdffrom binary or URL. - Email or store the filled PDF.
- Sheets trigger on new row.
- Set or Code node builds
{"firstname": "...", ...}. - PDF4me Generate Document (Single) with Pdf Form template.
- Upload output to Drive or SharePoint.
- HubSpot / Salesforce trigger on new contact.
- Map CRM properties to
firstname,lastname, etc. - Set Keep PDF Editable Off to flatten before archiving.
Frequently Asked Questions
Related Guides
- Generate Document (Single) overview: all parameters, output fields, and template types
- Fill a PDF Form: dedicated AcroForm fill without the generate template engine
- Extract Form Data From PDF: list field names from any PDF form