Zum Hauptinhalt springen

Füllen Sie ein PDF Bilden

Was dieser Endpunkt bewirkt

PDF4me Füllen Sie ein PDF-Formular aus füllt AcroForm-Felder in einem PDF Vorlage mit Werten aus einem JSON Objekt in einem einzelnen REST Anruf. Senden Sie die Vorlage als Base64 oder eine öffentliche URLSenden Sie die Feldwerte als Zeichenketten Datenarrayund erhalten Sie das gefüllte PDF als Binärbytes (200) oder über eine Location-Header-Abfrage URL (202). Umschalten PDF bearbeitbar halten um ein wiederbearbeitbares Formular oder einen flachen statischen Datensatz bereitzustellen.

Verwandte Blog-Beiträge
Zu dieser Funktion gibt es noch keinen Blogbeitrag – folgt in Kürze.
Schauen Sie sich in der Zwischenzeit im PDF4me-Blog Tutorials und Arbeitsabläufe für alle Plattformen an.
Besuchen Sie den Blog

Authentifizierung Ihres API Anfrage

Jeder PDF4me REST Der Anruf muss Ihre API Schlüssel im Authorization Header als Basic Auth. Ihren Schlüssel erhalten oder ändern Sie ihn im Entwickler-Dashboard.

Endpunkt

POST/api/v2/FillPdfForm

Wichtige Fakten, die Sie nicht verpassen sollten

Datenarray ist ein String, kein Objekt.
Der API erwartet einen String JSON. Verpacken Sie Ihre Formularnutzdaten immer in JSON.stringify({...}) vor dem Absenden. Das Senden eines verschachtelten Objekts führt zu einem Deserialisierungsfehler.
Die Schlüssel müssen exakt mit den AcroForm-Feldnamen übereinstimmen.
Feldnamen unterscheiden Groß- und Kleinschreibung. Überprüfen Sie die Vorlage mit Adobe Acrobat. Formular vorbereiten Oder rufen Sie zuerst den Endpunkt "Formulardaten extrahieren" auf, um eine saubere Liste aller ausfüllbaren Felder zu erhalten.
Async gibt 202 + Location-Header zurück
Mit IsAsync: true Die API kann mit dem Statuscode 202 und einem Location-Header antworten. GET Das URL (gleiche Autorisierung), bis der Statuscode 200 zurückgegeben wird. PDF Binär. Standard PDF4me asynchrones Muster (pdf4meAsyncRequest).

HTTP aufstellen

Verfahren: POST
URL: https://api.pdf4me.com/api/v2/FillPdfForm
Inhaltstyp: application/json
Genehmigung: Basic <Ihre PDF4me API Schlüssel>

Schicken IsAsync: true im Körper. 200 gibt das gefüllte Produkt zurück PDF als Binärbytes. 202 gibt ein zurück Standort Überschrift mit einer Umfrage URL; GET Das URL mit demselben Authorization-Header, bis es den Statuscode 200 zurückgibt. PDF binär (gleiche Konvention wie pdf4meAsyncRequest).

Variantenmatrix (für Postman relevant)

Drei Eingabevarianten decken jeden Postman-/curl-/SDK-Aufruf ab. Wählen Sie die Variante, die zu Ihrem Anwendungsfall passt. PDF Vorlagen- und Formulardaten werden live übertragen.

VariantePDF-Vorlage (templateDocContent)FormularfelderErforderliche API-Felder
ABase64 PDFJSON object → stringify → dataArrayAll rows in the JSON-form table below.
BPublic PDF URLJSON object → stringify → dataArraySame as A; templateDocContent is the URL string.
CBase64 PDFBase64-encoded JSON file → decode → stringify into dataArraySame as A; build dataArray from the decoded JSON.

API Körperfelder

Immer gesendet

FeldErforderlichTypStandard / Notizen
templateDocNameYes*stringFilename of the template, e.g. template.pdf. Derived from the source URL filename or defaulted to template.pdf. Used for downstream output naming.
templateDocContentYesstringBase64-encoded PDF (no data: prefix) OR a publicly reachable https URL to the PDF.
KeepPdfEditableNobooleanDefault false. Set true to keep AcroForm fields editable in the output PDF; false flattens the form into static text.
IsAsyncYesbooleanDefault true. Toggles the 200 / 202 + Location async pattern.

*templateDocName muss immer in der Anfrage angegeben werden; wählen Sie einen sinnvollen Dateinamen, damit die Ausgabedateinamen nachgelagert übersichtlich bleiben.

Wenn Formulareingabe JSON

FeldErforderlichTypAnmerkungen
dataArrayYesstringJSON.stringify({ ... }). Keys = AcroForm field names; values = strings to fill.
inputDataTypeYesstringAlways "json" for this path.
outputTypeYesstringAlways "pdf".

Formulardatenregeln (JSON Weg)

RegelDetail
ShapeSingle object: {"fieldName": "value", ...}.
Not allowedEmpty array, or an array of multiple objects.
Base64 form inputDecode the UTF-8 JSON file, then JSON.stringify into dataArray. In Postman: put the decoded-then-stringified result directly into dataArray.
Data URLStrip the data:...;base64, prefix if present (applies to the PDF Base64 in templateDocContent).

Beispielnutzlasten

Variante A. PDF Base64 + Formular JSON

{
"templateDocName": "application-form.pdf",
"templateDocContent": "JVBERi0xLjQKJcfsj6IKNSAwIG9iago8PAovVHlwZSAvQ2F0YWxvZw...",
"dataArray": "{\"firstname\": \"John\", \"lastname\": \"Doe\", \"email\": \"[email protected]\"}",
"inputDataType": "json",
"outputType": "pdf",
"KeepPdfEditable": false,
"IsAsync": true
}

Datenarray muss eine Zeichenkette sein, keine verschachtelte JSON Objekt:
"dataArray": "{"firstname":"John","lastname":"Doe"}"

Variante B. PDF-URL + Formular-JSON

{
"templateDocName": "application-form.pdf",
"templateDocContent": "https://example.com/forms/application-form.pdf",
"dataArray": "{\"firstname\": \"John\", \"lastname\": \"Doe\", \"email\": \"[email protected]\"}",
"inputDataType": "json",
"outputType": "pdf",
"KeepPdfEditable": false,
"IsAsync": true
}

Variante C. PDF Base64 + Formular aus Base64-JSON

Platzhalter im Repository: eyJmaXJzdG5hbWUiOiJKb2huIn0={"firstname":"John"}Die

Äquivalent API Körper nach dem Entschlüsseln des Formulars JSON:

{
"templateDocName": "application-form.pdf",
"templateDocContent": "JVBERi0xLjQKJcfsj6IKNSAwIG9iago8PAovVHlwZSAvQ2F0YWxvZw...",
"dataArray": "{\"firstname\": \"John\"}",
"inputDataType": "json",
"outputType": "pdf",
"KeepPdfEditable": false,
"IsAsync": true
}

Optional. Formular bearbeitbar lassen.

{
"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
}

Tipps zur Postboten-Abholung

Headers
Content-Type: application/json + Authorization: Basic <apiKey>.
Body
raw JSON. Copy one of the variant payloads above.
Response
Save as .pdf when status is 200 and the body is binary. If 202, GET the Location URL with the same Authorization until 200.
Field names
Must exactly match AcroForm names in the template. Use the Extract Form Data endpoint or a PDF editor if you are unsure.

curl-Beispiel

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

Kurzübersicht: erforderlich vs. optional (Postman)

FeldA (PDF b64)B (PDF-URL)C (Form b64 → JSON)
templateDocNameRequiredRequiredRequired
templateDocContentRequired (b64)Required (URL)Required (b64)
dataArrayRequiredRequiredRequired (from decoded JSON)
inputDataTypeRequired (json)Required (json)Required (json)
outputTypeRequired (pdf)Required (pdf)Required (pdf)
IsAsyncRequired (true)Required (true)Required (true)
KeepPdfEditableOptionalOptionalOptional

Codebeispiele

Häufig gestellte Fragen

Why must dataArray be a stringified JSON, not a nested object?+
The API contract defines dataArray as a string field. The engine parses the string server-side. Sending a nested object returns a deserialization error. Always wrap your form values with JSON.stringify before posting.
What happens when KeepPdfEditable is true?+
The output PDF retains its AcroForm field definitions so the recipient can re-edit values in any PDF viewer. KeepPdfEditable false (the default) flattens the form into static text, useful for delivering a locked record of what was submitted.
How do I know the exact AcroForm field names?+
Open the template in Adobe Acrobat (Prepare Form), use any PDF editor with field inspection, or call the PDF4me Extract Form Data endpoint first. Keys in your dataArray JSON must match those names exactly, including case.
When should I use Variant B (PDF URL) over Variant A (Base64)?+
Use Variant B when the template is already hosted at a publicly reachable HTTPS URL. It avoids the Base64 size bloat (~33%) and is the simplest path for templates pinned in S3, CDN, or your own static asset host. Use Variant A when the template is private or local.
How does the async flow work?+
Send IsAsync true. If the API returns 200, the PDF binary is in the body. If it returns 202, read the Location response header for a poll URL. GET that URL with the same Authorization header. Continue polling (commonly 10s intervals up to 15 retries) until it returns 200 with the PDF.
Can I send an array of multiple form-data objects?+
No. The REST contract requires a single object inside dataArray (after JSON.stringify). To fill many forms, call the endpoint once per form.
My PDF Base64 has a data: prefix. Do I strip it?+
Yes. The API expects raw Base64 in templateDocContent. Strip any data:application/pdf;base64, prefix before posting.
How do I get back something other than PDF?+
You cannot. outputType is fixed to pdf for this endpoint. To rasterize the filled PDF into PNG / JPEG, chain a downstream PDF4me Convert PDF to Image call.

Ähnliche Aktionen

Dieselbe Aufgabe auf anderen Plattformen

Hilfe erhalten