Füllen Sie ein PDF Bilden
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.
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
/api/v2/FillPdfFormhttps://api.pdf4me.com/api/v2/FillPdfFormWichtige Fakten, die Sie nicht verpassen sollten
Datenarray ist ein String, kein Objekt.JSON.stringify({...}) vor dem Absenden. Das Senden eines verschachtelten Objekts führt zu einem Deserialisierungsfehler.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.
| Variante | PDF-Vorlage (templateDocContent) | Formularfelder | Erforderliche API-Felder |
|---|---|---|---|
| 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 Körperfelder
Immer gesendet
| Feld | Erforderlich | Typ | Standard / Notizen |
|---|---|---|---|
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 muss immer in der Anfrage angegeben werden; wählen Sie einen sinnvollen Dateinamen, damit die Ausgabedateinamen nachgelagert übersichtlich bleiben.
Wenn Formulareingabe JSON
| Feld | Erforderlich | Typ | Anmerkungen |
|---|---|---|---|
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". |
Formulardatenregeln (JSON Weg)
| Regel | 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). |
Beispielnutzlasten
Variante A. PDF Base64 + Formular JSON
{
"templateDocName": "application-form.pdf",
"templateDocContent": "JVBERi0xLjQKJcfsj6IKNSAwIG9iago8PAovVHlwZSAvQ2F0YWxvZw...",
"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",
"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
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)
| Feld | 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 |