Skip to main content

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

PDF with AcroForm fields
The sample 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.
Flat data object
Use 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.
PDF4me credential in n8n
Create a PDF4me credential in n8n and paste your API key. The same key works across all PDF4me nodes in your instance.
Pdf Form vs Fill a PDF Form

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 nameTypical use in templateSample value (formdata.json)
firstnameGiven nameJohn
lastnameFamily nameAdams
genderGender selectionFemale
memberMembership tierBasic
Field names vs visible labels

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 fieldJSON key (formdata.json)XML element (test.xml)CSV column (test.csv)Sample value
firstnamefirstnamefirstnamefirstnameJohn
lastnamelastnamelastnamelastnameAdams
gendergendergendergenderFemale
membermembermembermemberBasic

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
Stepn8n nodePurpose
1Manual TriggerStart the workflow on demand
2Read Binary FileLoads template.pdf into binary property data
3PDF4me → Generate Document (Single)Fills AcroForm fields from JSON/XML/CSV, outputs PDF
4Write Binary File or Send Email (optional)Saves or sends generated_document_output.pdf
Template File Type dropdown in n8n PDF4me Generate Document (Single) node showing Pdf Form among Word, HTML, Mail Merge, and Google Docs options

Set Template File Type to Pdf Form. Output Type is PDF only for this template type.


Step 1: Download and Place the Sample Files

  1. Download template.pdf and formdata.json from the Sample File Pack above.
  2. Save template.pdf somewhere n8n can read it (local path on self-hosted, or cloud storage for production triggers).
  3. Optionally download test.xml or test.csv to test other data types.

Step 2: Create the n8n Workflow

  1. In n8n, create a new workflow.
  2. Add a Manual Trigger node.
  3. Add a Read Binary File node after the trigger.
  4. Add PDF4me → Generate Document (Single) after Read Binary File.
  5. Connect your PDF4me credential.
HTML Code is not valid here

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)

FieldValue
File PathFull path to your downloaded template.pdf
Property Namedata (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

FieldValueNotes
Credential to connect withYour PDF4me credentialGet API key
ResourceGenerate
Generate OperationsGenerate Document (Single)
Template File TypePdf FormPDF with AcroForm fields
Output TypePDFOnly option for Pdf Form

Template input (from Read Binary File)

FieldValue
Template File Input TypeBinary Data
Template Binary Propertydata
Template File Nametemplate.pdf

Document data (paste JSON from formdata.json)

FieldValue
Document Data Input TypeText
Document Data TypeJSON
Document Data TextPaste the full contents of formdata.json (see block below)
{
"firstname": "John",
"lastname": "Adams",
"gender": "Female",
"member": "Basic"
}

Output options

FieldValueWhen to use
Keep PDF EditableOnRecipient should still edit fields in the filled PDF
Keep PDF EditableOff (default)Flatten form fields into static content
Binary Data Output Namedata (default)Binary property for the output PDF

Step 5: Execute and Verify the PDF

  1. Click Execute workflow.
  2. Open the PDF4me node output. Under Binary, open property data (generated_document_output.pdf).
  3. 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:

FieldValue
File Namefilled-form-output.pdf
Data Property Namedata
Output PathTarget 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)

  1. Add Read Binary File for formdata.json (use a Merge node if template and data share the workflow item).
  2. 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.
Binary property name collision

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:

FieldValue
Template File Input TypeURL
Template File URLPublic link to template.pdf
Template File Nametemplate.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 form submission
  1. Webhook receives registration payload.
  2. Map body fields to JSON keys matching AcroForm names.
  3. PDF4me fills fixed template.pdf from binary or URL.
  4. Email or store the filled PDF.
Google Sheets row to PDF
  1. Sheets trigger on new row.
  2. Set or Code node builds {"firstname": "...", ...}.
  3. PDF4me Generate Document (Single) with Pdf Form template.
  4. Upload output to Drive or SharePoint.
CRM contact to membership PDF
  1. HubSpot / Salesforce trigger on new contact.
  2. Map CRM properties to firstname, lastname, etc.
  3. Set Keep PDF Editable Off to flatten before archiving.

Frequently Asked Questions

How is Pdf Form different from Fill a PDF Form?+
Generate Document (Single) with Pdf Form is part of the generate template workflow (same node as Word and HTML). Fill a PDF Form is a dedicated Forms operation for any PDF with AcroForm fields. Both map keys to field names; choose Generate when Pdf Form is your Template File Type in a generate pipeline.
Why are some fields blank in the output?+
JSON keys must match AcroForm field names exactly, including case. firstname works; FirstName or first_name usually does not. Run Extract Form Data From PDF on template.pdf to list internal names before mapping CRM or webhook data.
Should I turn Keep PDF Editable on or off?+
On: fields remain editable (useful for review workflows). Off: fields are flattened into static text (better for final archival or when recipients should not change values). Default is Off.
Can Pdf Form output Word or HTML?+
No. When Template File Type is Pdf Form, Output Type is PDF only.
JSON vs XML vs CSV: which should I use?+
JSON is simplest for n8n expressions and webhooks. XML and CSV in the sample pack use the same four keys. All formats map one value per AcroForm field name.