Lewati ke konten utama

Gabungkan Beberapa PDF Berkas

PDF4me Gabungkan adalah sebuah REST titik akhir yang menggabungkan beberapa PDFs menjadi satu dokumen. POST serangkaian Base64-file yang dienkode ke /api/v2/Merge dengan nama keluaran, dan API Menambahkan elemen-elemen tersebut sesuai urutan array dan mengembalikan hasil gabungan. PDF sebagai byte mentah. Atur async berlaku untuk batch besar dan jajak pendapat Location URL sampai hasilnya siap.

Fungsi dari endpoint ini

Membutuhkan dua orang atau lebih PDFs dan mengembalikan satu: faktur plus lampiran, halaman sampul plus laporan, folder hasil pindaian yang dikonsolidasikan menjadi satu file. Urutan array adalah urutan halaman, sehingga kode Anda sepenuhnya mengontrol hasilnya. Ini adalah titik akhir penggabungan biasa; melapisi pages Menumpuk satu sama lain adalah tindakan terpisah (Gabungkan Hamparan).

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

POST/api/v2/Gabung

Fakta Penting yang Tidak Boleh Anda Lewatkan

docContent adalah sebuah array, dan urutan itu penting.
Tidak seperti kebanyakan PDF4me titik akhir di mana docContent adalah sebuah string tunggal, di sini berupa ARRAY dari Base64 string. Urutan array adalah urutan penggabungan; tidak ada parameter pengurutan terpisah.
Respons 200 adalah PDF dirinya sendiri
Tubuh adalah biner mentah, bukan sebuah JSON pembungkus. Tulis byte langsung ke .pdf berkas. JSON-menguraikan respons atau Base64-Mendekodekannya akan merusak output.
async true untuk batch besar
Dengan "asinkron": benar itu API jawaban 202 Accepted dengan Location judul. Lakukan jajak pendapat dengan GET kira-kira setiap 10 detik (contoh resmi menggunakan interval 10 detik, hingga 20 kali percobaan ulang) sampai 200 mengembalikan file yang telah digabungkan.

HTTP pengaturan

Metode: POST
URL: https://api.pdf4me.com/api/v2/Merge
Tipe Konten: aplikasi/json
Authorization: Dasar <Anda PDF4me API kunci>

Badan respons 200 adalah gabungan dari PDF Sebagai byte mentah: simpan langsung. Respons 202 berarti penggabungan berjalan secara asinkron: lakukan polling. Location URL sampai 200.

Apa perbedaan antara pemrosesan sinkron dan asinkron?

Yang async Flag mengubah kontrak respons, bukan hasil penggabungan. Pilih berdasarkan ukuran batch.

Sinkron vs asinkron"async": false (bawaan)"async": true
Tanggapan atas success200 dengan penggabungan PDF sebagai byte mentah202 Accepted dengan Location jajak pendapat URL
KoneksiTetap terbuka hingga proses penggabungan selesaiPengembalian segera
Bagaimana cara mendapatkan file tersebut?Simpan isi respons secara langsung.GET itu Location URL setiap ~10 detik hingga menjawab 200 dengan byte tersebut
Terbaik untukBeberapa berkas kecilKumpulan data besar dan dokumen besar

API bidang tubuh

ParameterDiperlukanJenisApa fungsinya?Contoh
docContentRequiredarray of stringsAn array of Base64-encoded PDF files, at least two entries. The array order is the merge order of the output document.["JVBERi0x...", "JVBERi0x..."]
docNameRequiredstringOutput filename for the merged PDF.merged.pdf
asyncOptionalbooleanfalse (default) returns the merged PDF directly on 200. true returns 202 plus a Location URL to poll, for large batches.true

Contoh muatan

Gabungkan dua PDFs secara sinkron

{
"docContent": [
"JVBERi0xLjcKJb...first PDF Base64...",
"JVBERi0xLjcKJb...second PDF Base64..."
],
"docName": "merged.pdf"
}

Gabungkan sejumlah besar data secara asinkron.

{
"docContent": [
"JVBERi0x...cover...",
"JVBERi0x...report...",
"JVBERi0x...appendix-a...",
"JVBERi0x...appendix-b..."
],
"docName": "quarterly-pack.pdf",
"async": true
}

Tips pengambilan oleh tukang pos

Headers
Content-Type: application/json + Authorization: Basic <apiKey>.
Body
raw JSON. docContent is an ARRAY of Base64 strings, one per source PDF, in merge order.
Response
On 200, switch Postman to "Send and Download": the body is the PDF itself, not JSON.
Async
With async true, copy the Location header from the 202 response into a GET request and poll it until 200.

contoh curl

curl -X POST https://api.pdf4me.com/api/v2/Merge \
-H "Content-Type: application/json" \
-H "Authorization: Basic YOUR_API_KEY" \
-d '{
"docContent": [
"'"$(base64 -w 0 first.pdf)"'",
"'"$(base64 -w 0 second.pdf)"'"
],
"docName": "merged.pdf"
}' \
--output merged.pdf

Apa yang dimaksud dengan API kembali?

BidangJenisIsi di dalamnya
200 response bodyBinary (application/pdf)The merged PDF file itself as raw bytes. Save it directly to disk; do not JSON-parse or Base64-decode.
202 Location headerURLAsync mode only: the polling URL. GET it about every 10 seconds until it returns 200 with the merged PDF bytes.
4xx/5xx response bodyJSON or textError details: 400 for malformed Base64 or a bad payload shape, 401 for a missing or invalid API key, 500 for server-side processing failures.

Contoh kode

Contoh resmi yang dapat dijalankan untuk endpoint persis ini, sesuai dengan language:

Pertanyaan yang Sering Diajukan (FAQ)

How is the merge order decided?+
By the docContent array order. The first Base64 string becomes the first pages of the output, the second is appended after it, and so on. Reorder the array to reorder the merged document.
Is the response JSON with a Base64 file inside?+
No. A 200 response body is the merged PDF itself as raw binary bytes. Write response.content straight to a .pdf file; do not JSON-parse or Base64-decode it.
When should I set async to true?+
For large batches or big files. With async true the API returns 202 Accepted plus a Location header; poll that URL with GET requests about every 10 seconds until it returns 200 with the merged PDF.
Can I merge Word or Excel files with this endpoint?+
No. /api/v2/Merge accepts PDFs only. Merge Word files with the Merge Documents Word endpoint, or convert other formats to PDF first and then merge the results here.
How many PDFs can I merge in one call?+
The docContent array accepts multiple documents in a single request; two entries is the minimum meaningful merge. For very large batches, set async true so the merge runs server-side while you poll for the result.
What is the difference between Merge and Merge Overlay?+
Merge appends documents one after another, page by page. Merge Overlay stamps the pages of one PDF on top of the pages of another, which is what you want for letterheads and backgrounds.
Why am I getting a 400 Bad Request?+
The usual causes are a docContent that is a single string instead of an array, an entry that is not valid Base64, or a source file that is not actually a PDF. Encode each file separately and keep the array shape.

Mengapa bergabung? PDFs melalui API alih-alih alat desktop?

Alat penggabungan file desktop dan web cocok untuk pekerjaan sekali jalan, tetapi alat ini membutuhkan campur tangan manusia untuk memilih file, menyeretnya agar berurutan, dan mengunduh hasilnya. API Fungsi ini melakukan penggabungan yang sama seperti satu permintaan deterministik per batch, dengan urutan yang ditentukan oleh kode Anda, bukan dengan metode seret dan lepas. Outputnya adalah standar. PDF sesuai dengan ISO Spesifikasi 32000, sehingga dapat dibuka di pembaca mana pun dan masuk dengan lancar ke langkah pipeline berikutnya, baik itu kompresi, OCRatau tanda tangan elektronik.

Tindakan terkait

Tugas yang sama di platform lain

Dapatkan Bantuan