Fill a PDF Form
PDF4me Fill a PDF Form populates AcroForm fields in a PDF template with values from a JSON object in a single REST call. Send the template as Base64 or a public URL, send the field values as a stringified dataArray, and receive the filled PDF as binary bytes (200) or via a Location-header poll URL (202). Toggle KeepPdfEditable to deliver a re-editable form or a flattened static record.
Authenticating Your API Request
Every PDF4me REST call must include your API key in the Authorization header as Basic auth. Get or rotate your key from the developer dashboard.
Endpoint
/api/v2/FillPdfFormhttps://api.pdf4me.com/api/v2/FillPdfFormImportant Facts You Should Not Miss
dataArray is a STRING, not an objectJSON.stringify({...}) before posting. Sending a nested object returns a deserialization error.IsAsync: true the API may respond 202 and a Location header. GET that URL (same Authorization) until it returns 200 with the PDF binary. Standard PDF4me async pattern (pdf4meAsyncRequest).HTTP setup
Method: POST
URL: https://api.pdf4me.com/api/v2/FillPdfForm
Content-Type: application/json
Authorization: Basic <your PDF4me API key>
Send IsAsync: true in the body. 200 returns the filled PDF as binary bytes. 202 returns a Location header with a poll URL; GET that URL with the same Authorization header until it returns 200 with the PDF binary (same convention as pdf4meAsyncRequest).
Variant matrix (Postman-relevant)
Three input variants cover every Postman / curl / SDK call. Pick the variant that matches where your PDF template and form data live.
| Variant | PDF template (templateDocContent) | Form fields | Required API fields |
|---|---|---|---|
| A | Base64 PDF | JSON object → stringify → dataArray | All rows in the JSON-form table below. |
| B | Public PDF URL | JSON object → stringify → dataArray | Same as A; templateDocContent is the URL string. |
| C | Base64 PDF | Base64-encoded JSON file → decode → stringify into dataArray | Same as A; build dataArray from the decoded JSON. |
API body fields
Always sent
| Field | Required | Type | Default / notes |
|---|---|---|---|
templateDocName | Yes* | string | Filename of the template, e.g. template.pdf. Derived from the source URL filename or defaulted to template.pdf. Used for downstream output naming. |
templateDocContent | Yes | string | Base64-encoded PDF (no data: prefix) OR a publicly reachable https URL to the PDF. |
KeepPdfEditable | No | boolean | Default false. Set true to keep AcroForm fields editable in the output PDF; false flattens the form into static text. |
IsAsync | Yes | boolean | Default true. Toggles the 200 / 202 + Location async pattern. |
*templateDocName must always be set in the request; pick a sensible filename so output filenames are clean downstream.
When form input is JSON
| Field | Required | Type | Notes |
|---|---|---|---|
dataArray | Yes | string | JSON.stringify({ ... }). Keys = AcroForm field names; values = strings to fill. |
inputDataType | Yes | string | Always "json" for this path. |
outputType | Yes | string | Always "pdf". |
Form data rules (JSON path)
| Rule | Detail |
|---|---|
| Shape | Single object: {"fieldName": "value", ...}. |
| Not allowed | Empty array, or an array of multiple objects. |
| Base64 form input | Decode the UTF-8 JSON file, then JSON.stringify into dataArray. In Postman: put the decoded-then-stringified result directly into dataArray. |
| Data URL | Strip the data:...;base64, prefix if present (applies to the PDF Base64 in templateDocContent). |
Sample payloads
Variant A. PDF Base64 + form JSON
{
"templateDocName": "application-form.pdf",
"templateDocContent": "JVBERi0xLjQKJcfsj6IKNSAwIG9iago8PAovVHlwZSAvQ2F0YWxvZw...",
"inputDataType": "json",
"outputType": "pdf",
"KeepPdfEditable": false,
"IsAsync": true
}
dataArray must be a string, not a nested JSON object:
"dataArray": "{"firstname":"John","lastname":"Doe"}"
Variant B. PDF URL + form JSON
{
"templateDocName": "application-form.pdf",
"templateDocContent": "https://example.com/forms/application-form.pdf",
"inputDataType": "json",
"outputType": "pdf",
"KeepPdfEditable": false,
"IsAsync": true
}
Variant C. PDF Base64 + form from base64 JSON
Placeholder in repo: eyJmaXJzdG5hbWUiOiJKb2huIn0= → {"firstname":"John"}.
Equivalent API body after decoding the form JSON:
{
"templateDocName": "application-form.pdf",
"templateDocContent": "JVBERi0xLjQKJcfsj6IKNSAwIG9iago8PAovVHlwZSAvQ2F0YWxvZw...",
"dataArray": "{\"firstname\": \"John\"}",
"inputDataType": "json",
"outputType": "pdf",
"KeepPdfEditable": false,
"IsAsync": true
}
Optional. keep form editable
{
"templateDocName": "application-form.pdf",
"templateDocContent": "https://example.com/forms/application-form.pdf",
"dataArray": "{\"firstname\": \"John\", \"lastname\": \"Doe\"}",
"inputDataType": "json",
"outputType": "pdf",
"KeepPdfEditable": true,
"IsAsync": true
}
Postman collection tips
curl example
curl -X POST https://api.pdf4me.com/api/v2/FillPdfForm \
-H "Content-Type: application/json" \
-H "Authorization: Basic YOUR_API_KEY" \
-d '{
"templateDocName": "application-form.pdf",
"templateDocContent": "https://example.com/forms/application-form.pdf",
"dataArray": "{\"firstname\":\"John\",\"lastname\":\"Doe\"}",
"inputDataType": "json",
"outputType": "pdf",
"KeepPdfEditable": false,
"IsAsync": true
}' \
--output filled-form.pdf
Quick reference: required vs optional (Postman)
| Field | A (PDF b64) | B (PDF URL) | C (form b64 → JSON) |
|---|---|---|---|
templateDocName | Required | Required | Required |
templateDocContent | Required (b64) | Required (URL) | Required (b64) |
dataArray | Required | Required | Required (from decoded JSON) |
inputDataType | Required (json) | Required (json) | Required (json) |
outputType | Required (pdf) | Required (pdf) | Required (pdf) |
IsAsync | Required (true) | Required (true) | Required (true) |
KeepPdfEditable | Optional | Optional | Optional |