Isi PDF Membentuk
PDF4me Isi Formulir PDF mengisi kolom AcroForm di PDF templat dengan nilai dari sebuah JSON objek dalam satu REST Telepon. Kirim templat sebagai Base64 atau publik URL, kirim nilai field sebagai string. dataArraydan menerima formulir yang telah diisi. PDF sebagai byte biner (200) atau melalui polling header Lokasi URL (202). Beralih KeepPdfEditable untuk menghasilkan formulir yang dapat diedit ulang atau catatan statis yang diratakan.
Memverifikasi Identitas Anda API Meminta
Setiap PDF4me REST panggilan harus menyertakan Anda API kunci di Authorization Header sebagai otentikasi Dasar. Dapatkan atau putar kunci Anda dari dasbor pengembang.
Titik akhir
/api/v2/FillPdfFormhttps://api.pdf4me.com/api/v2/FillPdfFormFakta Penting yang Tidak Boleh Anda Lewatkan
dataArray adalah STRING, bukan objek.JSON.stringify({...}) Sebelum mengirim. Mengirim objek bersarang akan menghasilkan kesalahan deserialisasi.IsAsync: true itu API Mungkin akan merespons dengan kode 202 dan header Lokasi. GET itu URL (Otorisasi yang sama) hingga mengembalikan kode 200 dengan PDF biner. Standar PDF4me pola asinkron (pdf4meAsyncRequest).HTTP pengaturan
Metode: POS
URL: https://api.pdf4me.com/api/v2/FillPdfForm
Tipe Konten: aplikasi/json
Otorisasi: Dasar <Anda PDF4me API kunci>
Mengirim IsAsync: true di dalam tubuh. 200 mengembalikan yang sudah terisi PDF sebagai byte biner. 202 mengembalikan Lokasi header dengan jajak pendapat URL; GET itu URL dengan header Otorisasi yang sama hingga mengembalikan kode 200 dengan PDF biner (konvensi yang sama seperti pdf4meAsyncRequest).
Matriks varian (relevan dengan Postman)
Tiga varian input mencakup setiap panggilan Postman / curl / SDK. Pilih varian yang sesuai dengan kebutuhan Anda. PDF Data templat dan formulir bersifat langsung.
| Variasi | Templat PDF (templateDocContent) | Kolom formulir | Kolom API yang wajib diisi |
|---|---|---|---|
| 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 bidang tubuh
Selalu dikirim
| Bidang | Diperlukan | Jenis | Catatan/Default |
|---|---|---|---|
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. |
*templatDocName harus selalu dicantumkan dalam permintaan; pilih nama file yang masuk akal agar nama file keluaran tetap rapi di tahap selanjutnya.
Saat input formulir JSON
| Bidang | Diperlukan | Jenis | Catatan |
|---|---|---|---|
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". |
Aturan data formulir (JSON jalur)
| Aturan | 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). |
Contoh muatan
Varian A. PDF Base64 + formulir JSON
{
"templateDocName": "application-form.pdf",
"templateDocContent": "JVBERi0xLjQKJcfsj6IKNSAwIG9iago8PAovVHlwZSAvQ2F0YWxvZw...",
"inputDataType": "json",
"outputType": "pdf",
"KeepPdfEditable": false,
"IsAsync": true
}
dataArray harus berupa string, bukan bersarang. JSON objek:
"dataArray": "{"firstname":"John","lastname":"Doe"}"
Varian B. URL PDF + formulir JSON
{
"templateDocName": "application-form.pdf",
"templateDocContent": "https://example.com/forms/application-form.pdf",
"inputDataType": "json",
"outputType": "pdf",
"KeepPdfEditable": false,
"IsAsync": true
}
Varian C. PDF Base64 + formulir dari JSON base64
Placeholder di repositori: eyJmaXJzdG5hbWUiOiJKb2huIn0= → {"firstname":"John"}.
Setara API tubuh setelah mendekode formulir JSON:
{
"templateDocName": "application-form.pdf",
"templateDocContent": "JVBERi0xLjQKJcfsj6IKNSAwIG9iago8PAovVHlwZSAvQ2F0YWxvZw...",
"dataArray": "{\"firstname\": \"John\"}",
"inputDataType": "json",
"outputType": "pdf",
"KeepPdfEditable": false,
"IsAsync": true
}
Opsional. Biarkan formulir tetap dapat diedit.
{
"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
}
Tips pengambilan oleh tukang pos
contoh curl
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
Referensi cepat: wajib vs opsional (Postman)
| Bidang | A (PDF b64) | B (URL PDF) | C (formulir 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 |