メインコンテンツへスキップ

複数のものを結合する PDF ファイル

PDF4me マージ は REST 複数のエンドポイントを組み合わせる PDFs 単一の文書にまとめる。 POST 配列 Base64-エンコードされたファイルを /api/v2/Merge 出力名と、 API 配列の順序で追加し、マージされたものを返します。 PDF 生バイトとして設定します。 async 大きなバッチの場合、そしてポーリングの場合に当てはまります Location URL 結果が出るまで。

このエンドポイントの機能

2個以上必要 PDFs そして、請求書と添付ファイル、表紙とレポート、スキャンした画像を1つのファイルにまとめたフォルダなど、1つの結果を返します。配列の順序はページの順序なので、コードで結果を完全に制御できます。これは単純な連結エンドポイントです。オーバーレイ pages 重ね合わせる操作は別個のものです(オーバーレイの結合)。

関連ブログ記事
この機能に関するブログ記事はまだありません。近日公開予定です。
その間、PDF4me ブログを閲覧して、あらゆるプラットフォームのチュートリアルやワークフローをご覧ください。
ブログをご覧ください →

認証 API リクエスト​

毎 PDF4me REST 電話にはあなたの API キー Authorization ヘッダーを基本認証として設定します。開発者ダッシュボードからキーを取得またはローテーションしてください。

終点​

POST/api/v2/Merge

見逃してはならない重要な事実​

docContent は配列であり、順序が重要です
ほとんどの人とは違って PDF4me エンドポイント docContent は単一の文字列ですが、ここでは配列です。 Base64 文字列。配列の順序はマージ順序であり、個別の順序付けパラメータはありません。
200 レスポンスは PDF それ自体
本体は生のバイナリであり、 JSON ラッパー。バイトを直接 に書き込みます。pdf ファイル。 JSON-レスポンスを解析または Base64デコードすると出力が破損します。
大きなバッチの場合は async true が有効になります
と 「async」: true の API 回答202 Accepted と共に Location ヘッダー。ポーリングして GET 約 10 秒ごと (公式サンプルでは 10 秒間隔で最大 20 回再試行) に、マージされたファイルが 200 で返されるまで実行されます。

HTTP 設定​

方法: POST
URL: https://api.pdf4me.com/api/v2/Merge
コンテンツタイプ: アプリケーション/json
Authorization: 基本 <あなたの PDF4me API キー>

200レスポンスボディはマージされた PDF 生のバイトとして: 直接保存します。202 レスポンスはマージが非同期で実行されていることを意味します: ポーリングします Location URL 200まで。

同期処理と非同期処理の違いは何ですか?​

の async フラグはレスポンスの契約内容を変更するものであり、マージ結果を変更するものではありません。バッチサイズで選択してください。

同期 vs 非同期"async": false (デフォルト)"async": true
回答 success200 合併 PDF 生バイトとして202 Accepted と共に Location 世論調査 URL
繋がりマージが完了するまで開いたままにしておくすぐに返送
ファイルの入手方法レスポンスボディを直接保存するGET の Location URL 約10秒ごとに、バイト列で200の応答が返されるまで続きます。
最適いくつかの小さなファイル大量のデータと大きなドキュメント

API ボディフィールド​

パラメータ必須その機能例
jobIdExtOptionalYour own reference for this call. It is stored with the API call log so you can correlate calls with your jobs. Type: string.
integrationsOptionalIntegration identifiers, forwarded unchanged with the job's notification settings. Type: array.
isAsyncOptionalSet to `true` to process the action asynchronously and get a job to poll at `/api/v2/GetActionStatus`. Only honoured by actions that support asynchronous processing. Type: boolean.true
docNameOptionalFile name of the merged output PDF, e.g. `merged.pdf`. Type: string.merged.pdf
docContentOptionalThe source documents to merge, each base64-encoded, in merge order. Type: array.["JVBERi0x...", "JVBERi0x..."]
documentUrlOptionalNot needed; set by the API when an entry of `docContent` is a URL. Type: string.

サンプルペイロード​

2つを結合する PDFs 同期的に​

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

大量のデータを非同期でマージする​

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

郵便配達員の集荷に関するヒント​

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の例​

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

何が API 戻る?​

分野タイプ内容物
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.

コードサンプル​

このエンドポイントの公式実行可能サンプルは、 language:

よくある質問​

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.

合併する理由 PDFs 経由 API デスクトップツールの代わりに?​

デスクトップやウェブのマージツールは単発の作業には適していますが、ファイルを選択してドラッグして順番に並べ、結果をダウンロードするには人間が必要です。 API バッチごとに1つの決定論的なリクエストと同じ連結処理を実行しますが、順序はドラッグアンドドロップではなくコードによって固定されます。出力は標準です。 PDF に準拠する ISO 32000仕様なので、どのリーダーでも開いて、圧縮などの次のパイプラインステップにきれいに送り込むことができます。 OCRまたは電子署名。

関連アクション​

他のプラットフォームでも同じタスクを実行​

ヘルプが必要な場合​