Ana içeriğe geç

Birden Fazlasını Birleştir PDF Dosyalar

PDF4me Birleştir bir REST birden fazlasını birleştiren uç nokta PDFs tek bir belgeye dönüştürün. POST bir dizi Base64-kodlanmış dosyaları /api/v2/Merge bir çıktı adı ile ve API Bunları dizi sırasına göre ekler ve birleştirilmiş sonucu döndürür. PDF Ham baytlar olarak. Ayarla async büyük partiler ve anketler için doğru Location URL Sonuç hazır olana kadar.

Bu uç noktanın işlevi

İki veya daha fazla kişi gerektirir. PDFs ve tek bir sonuç döndürür: fatura ve ekler, kapak sayfası ve rapor, tek bir dosyada birleştirilmiş tarama dosyaları klasörü. Dizi sırası sayfa sırasıdır, bu nedenle kodunuz sonucu tamamen kontrol eder. Bu, düz birleştirme uç noktasıdır; üst üste bindirme pages Üst üste bindirme işlemi ayrı bir eylemdir (Birleştirme Katmanı).

İlgili Blog Yazıları
Bu özellik için henüz bir blog yazısı yok — yakında yayınlanacak.
Bu arada, her platforma yönelik eğitimler ve iş akışları için PDF4me bloguna göz atın.
Blogu ziyaret edin

Kimliğinizi Doğrulama API Rica etmek

Her PDF4me REST Çağrınızda mutlaka sizin de bulunmanız gerekiyor. API anahtara Authorization Başlıkta Temel kimlik doğrulama (Basic auth) belirtilmiştir. Anahtarınızı geliştirici kontrol panelinden alın veya değiştirin.

Uç nokta

POST/api/v2/Birleştir

Kaçırmamanız Gereken Önemli Bilgiler

docContent Bu bir dizidir ve sıralama önemlidir.
Çoğunun aksine PDF4me uç noktalar docContent burada tek bir dizedir, burada ise bir DİZİ'dir. Base64 Dizeler. Dizi sırası, birleştirme sırasıdır; ayrı bir sıralama parametresi yoktur.
200 yanıtı şudur: PDF kendisi
Gövde ham ikili veridir, bir şey değildir. JSON Sarmalayıcı. Baytları doğrudan bir dosyaya yazın.pdf dosya. JSON-yanıtı ayrıştırmak veya Base64-Bunu çözmek çıktıyı bozar.
Büyük veri kümeleri için async true
İle "asenkron": doğru o API 202 cevap Accepted ile Location başlık. Bunu sorgula. GET Yaklaşık her 10 saniyede bir (resmi örnekler 10 saniyelik aralıklar kullanır, 20'ye kadar yeniden deneme yapılabilir) 200'e kadar birleştirilmiş dosya döndürülür.

HTTP kurmak

Yöntem: POST
URL: https://api.pdf4me.com/api/v2/Merge
İçerik Türü: uygulama/json
Authorization: Temel <sizin PDF4me API anahtar>

200 yanıt gövdesi birleştirilmiş haldedir. PDF Ham baytlar olarak: doğrudan kaydedin. 202 yanıtı, birleştirmenin eşzamansız olarak çalıştığı anlamına gelir: yoklama yapın. Location URL 200'e kadar.

Senkron ve asenkron işlemleme arasındaki farklar nelerdir?

O async Bayrak, birleştirme sonucunu değil, yanıt sözleşmesini değiştirir. Toplu işlem boyutuna göre seçim yapın.

Senkron ve asenkron"async": false (varsayılan)"async": true
Yanıt success200 birleştirilmiş halde PDF ham baytlar olarak202 Accepted ile Location anket URL
BağlantıBirleştirme işlemi tamamlanana kadar açık tutulur.Hemen iade edilir.
Dosyayı nasıl alabilirim?Yanıt gövdesini doğrudan kaydedin.GET o Location URL Her ~10 saniyede bir, baytlarla 200 yanıtını verene kadar.
En iyisibirkaç küçük dosyaBüyük partiler ve büyük belgeler

API vücut alanları

ParametreGerekliTipNe işe yarar?Örnek
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

Örnek yükler

İkisini birleştirin PDFs eş zamanlı olarak

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

Büyük bir veri grubunu eşzamansız olarak birleştirin.

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

Postacı tahsilat ipuçları

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.

curl örneği

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

Ne anlama geliyor? API geri dönmek?

AlanTipİçeriğinde neler var?
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.

Kod örnekleri

Bu uç nokta için resmi, çalıştırılabilir örnekler, language:

SSS

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.

Neden birleşme PDFs aracılığıyla API Masaüstü aracı yerine mi?

Masaüstü ve web birleştirme araçları tek seferlik işler için uygundur, ancak dosyaları seçmek, sıralamak ve sonucu indirmek için bir insan müdahalesine ihtiyaç duyarlar. API Bu, her bir toplu işlem için tek bir deterministik istekle aynı birleştirmeyi yapar; ancak sıralama sürükle-bırak yöntemiyle değil, kodunuz tarafından belirlenir. Çıktı standarttır. PDF uygun olarak ISO 32000 spesifikasyonuBu nedenle herhangi bir okuyucuda açılır ve sıkıştırma gibi bir sonraki işlem adımına sorunsuz bir şekilde aktarılır. OCRveya elektronik imzalama.

İlgili işlemler

Diğer platformlarda aynı görev

Yardım Alın