複数のものを結合する PDF ファイル
PDF4me マージ は REST 複数のエンドポイントを組み合わせる PDFs 単一の文書にまとめる。 POST 配列 Base64-エンコードされたファイルを /api/v2/Merge 出力名と、 API 配列の順序で追加し、マージされたものを返します。 PDF 生バイトとして設定します。 async 大きなバッチの場合、そしてポーリングの場合に当てはまります Location URL 結果が出るまで。
2個以上必要 PDFs そして、請求書と添付ファイル、表紙とレポート、スキャンした画像を1つのファイルにまとめたフォルダなど、1つの結果を返します。配列の順序はページの順序なので、コードで結果を完全に制御できます。これは単純な連結エンドポイントです。オーバーレイ pages 重ね合わせる操作は別個のものです(オーバーレイの結合)。
認証 API リクエスト
毎 PDF4me REST 電話にはあなたの API キー Authorization ヘッダーを基本認証として設定します。開発者ダッシュボードからキーを取得またはローテーションしてください。
終点
/api/v2/Mergehttps://api.pdf4me.com/api/v2/Merge見逃してはならない重要な事実
docContent は単一の文字列ですが、ここでは配列です。 Base64 文字列。配列の順序はマージ順序であり、個別の順序付けパラメータはありません。「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 |
|---|---|---|
| 回答 success | 200 合併 PDF 生バイトとして | 202 Accepted と共に Location 世論調査 URL |
| 繋がり | マージが完了するまで開いたままにしておく | すぐに返送 |
| ファイルの入手方法 | レスポンスボディを直接保存する | GET の Location URL 約10秒ごとに、バイト列で200の応答が返されるまで続きます。 |
| 最適 | いくつかの小さなファイル | 大量のデータと大きなドキュメント |
API ボディフィールド
| パラメータ | 必須 | その機能 | 例 |
|---|---|---|---|
| jobIdExt | Optional | Your own reference for this call. It is stored with the API call log so you can correlate calls with your jobs. Type: string. | |
| integrations | Optional | Integration identifiers, forwarded unchanged with the job's notification settings. Type: array. | |
| isAsync | Optional | Set 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 |
| docName | Optional | File name of the merged output PDF, e.g. `merged.pdf`. Type: string. | merged.pdf |
| docContent | Optional | The source documents to merge, each base64-encoded, in merge order. Type: array. | ["JVBERi0x...", "JVBERi0x..."] |
| documentUrl | Optional | Not 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
}
郵便配達員の集荷に関するヒント
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 body | Binary (application/pdf) | The merged PDF file itself as raw bytes. Save it directly to disk; do not JSON-parse or Base64-decode. |
202 Location header | URL | Async mode only: the polling URL. GET it about every 10 seconds until it returns 200 with the merged PDF bytes. |
4xx/5xx response body | JSON or text | Error 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:
よくある質問
合併する理由 PDFs 経由 API デスクトップツールの代わりに?
デスクトップやウェブのマージツールは単発の作業には適していますが、ファイルを選択してドラッグして順番に並べ、結果をダウンロードするには人間が必要です。 API バッチごとに1つの決定論的なリクエストと同じ連結処理を実行しますが、順序はドラッグアンドドロップではなくコードによって固定されます。出力は標準です。 PDF に準拠する ISO 32000仕様なので、どのリーダーでも開いて、圧縮などの次のパイプラインステップにきれいに送り込むことができます。 OCRまたは電子署名。