Lewati ke konten utama

Isi PDF Membentuk

Fungsi dari endpoint ini

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.

Postingan Blog Terkait
Belum ada postingan blog untuk fitur ini — akan segera hadir.
Sementara itu, jelajahi blog PDF4me untuk menemukan tutorial dan alur kerja di berbagai platform.
Kunjungi blog ini

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

POS/api/v2/FillPdfForm

Fakta Penting yang Tidak Boleh Anda Lewatkan

dataArray adalah STRING, bukan objek.
Yang API mengharapkan string yang sudah diubah menjadi teks JSONSelalu bungkus muatan formulir Anda dengan JSON.stringify({...}) Sebelum mengirim. Mengirim objek bersarang akan menghasilkan kesalahan deserialisasi.
Kunci harus sama persis dengan nama kolom AcroForm.
Nama kolom peka terhadap huruf besar dan kecil. Periksa templat dengan Adobe Acrobat. Siapkan Formulir atau panggil endpoint Ekstrak Data Formulir terlebih dahulu untuk mendapatkan daftar lengkap semua kolom yang dapat diisi.
Async mengembalikan 202 + header Lokasi
Dengan 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.

VariasiTemplat PDF (templateDocContent)Kolom formulirKolom API yang wajib diisi
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 bidang tubuh

Selalu dikirim

BidangDiperlukanJenisCatatan/Default
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.

*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

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

Aturan data formulir (JSON jalur)

AturanDetail
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).

Contoh muatan

Varian A. PDF Base64 + formulir JSON

{
"templateDocName": "application-form.pdf",
"templateDocContent": "JVBERi0xLjQKJcfsj6IKNSAwIG9iago8PAovVHlwZSAvQ2F0YWxvZw...",
"dataArray": "{\"firstname\": \"John\", \"lastname\": \"Doe\", \"email\": \"[email protected]\"}",
"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",
"dataArray": "{\"firstname\": \"John\", \"lastname\": \"Doe\", \"email\": \"[email protected]\"}",
"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

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.

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)

BidangA (PDF b64)B (URL PDF)C (formulir 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

Contoh kode

Pertanyaan yang Sering Diajukan (FAQ)

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.

Tindakan terkait

Tugas yang sama di platform lain

Dapatkan Bantuan