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

文書を生成する(複数)

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

PDF4me 文書を生成する(複数) 複数のドキュメントを一度にレンダリングします REST 電話。単語を1つ送信します。 HTML、 または PDF テンプレート (Base64、 URLまたは生 HTML)とレコードの配列(JSON または XMLテキストとして、 Base64 ファイル、または URL) を返します。 JSON 生成されたファイルのリスト(レコードごとに1エントリ) Base64 で outputDocuments[].streamFileまたは、応答に応じて単一のバイナリ値。

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

認証 API リクエスト​

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

終点​

役職/api/v2/GenerateDocumentMultiple

エンドポイント名は ドキュメントを複数生成する (単数形) 書類)、 ない 複数のドキュメントを生成する。

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

1つのテンプレート、多数のレコード
送信 JSON 配列(または繰り返しレコード) XMLデータペイロードに ) が含まれます。エンジンは配列要素ごとに 1 つの出力ドキュメントをレンダリングし、それらをまとめて返します。
応答は通常 JSON outputDocuments[]
各エントリーには ファイル名 そしてbase64 ストリームファイル (時々 ファイルコンテンツ、 コンテンツ、 または データ各base64文字列をデコードしてファイルを保存します。
シングルとの違い:CSV、xlsx形式は不可、テンプレートの種類が少ない
テンプレートの種類は以下に限定されます Docx、 HTML、 PDFデータ型は以下に限定されます JSON、 XML出力は追加します xlsx Word用 / PDF テンプレート。

HTTP 設定​

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

送信 IsAsync: true 体内で。 200 戻ってくるかもしれない JSON と outputDocuments[] または単一のバイナリファイル。 202 を返します 位置 アンケート付きのヘッダー URL。

違いとドキュメント生成(単一)の比較​

トピック複数シングル
Endpoint/api/v2/GenerateDocumentMultiple/api/v2/GenerateDocumentSingle
templateFileTypeDocx, HTML, PDF onlyAlso MailMerge, GoogleDocs
documentDataTypeJson, XML onlyAlso Csv
outputTypePDF, Docx, xlsx (Word/PDF), HTMLNo xlsx
Data shapeTypically array of records (one doc per row)Usually one object
outputFileNameIntegration-UI only (output naming)Not in API body either

変異マトリックス(ポストマン関連)​

テンプレート (templateFileData)​

コードソース郵便配達員の価値また、必須です。
T1Base64Base64 template (strip data:...;base64, prefix if present)templateFileName
T2URLHTTPS URL stringtemplateFileName
T3HTML codeBase64(UTF-8 HTML): Buffer.from(html, "utf8").toString("base64")templateFileName, templateFileType: HTML

文書データ​

コードソースAPIフィールド郵便配達員の価値
D1TextdocumentDataTextJSON array (or XML with multiple records)
D2Base64documentDataFileBase64 of the .json / .xml file
D3URLdocumentDataFileURL to the data file

どちらかを使用してください ドキュメントデータテキスト または ドキュメントデータファイル (使用しないフィールドは省略してください。)

templateFileType → 許可された出力タイプ​

テンプレートファイルタイプ許可された 出力タイプ
DocxPDF, Docx, xlsx
PDFPDF, Docx, xlsx
HTMLHTML only

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
templateFileTypeOptionalType of the template file, e.g. `Docx`, `Html` or `Pdf`. Not used by GenerateDocumentSingleV2.Docx, HTML, PDF
templateFileDataOptionalRequired. The template file. Accepts the base64-encoded file content, a `pdf4meblobid://<id>` reference, or an `https` URL. Not used by GenerateDocumentSingleV2, which loads the stored template named by `templateFileName`. Type: string.Base64 template, or template URL
documentDataTypeOptionalFormat of the data, `Json`, `XML` or `Csv`.Json or XML (exact casing)
templateFileNameOptionalRequired. File name of the template, including its extension. For GenerateDocumentSingleV2 it is the name of a template uploaded in the PDF4me Dashboard (https://dev.pdf4me.com/dashboard/#/document-template/), which is loaded instead of `templateFileData`. Type: string.e.g. template.docx, template.html, template.pdf
documentDataTextOptionalThe data as text. Used when `documentDataFile` is empty. Type: string.Valid JSON (JSON.parse) or XML-like for XML
documentDataFileOptionalThe data as a file. Accepts the base64-encoded file content, a `pdf4meblobid://<id>` reference, or an `https` URL. Takes precedence over `documentDataText`. Type: string.Base64 data file or URL
outputTypeOptionalFormat of the generated document, e.g. `pdf` or `docx`. Not used by GenerateDocumentSingleV2.PDF, Docx, xlsx, or HTML
metaDataJsonOptionalOptional document metadata as a JSON string. Type: string.
keepPdfEditableOptionalKeep form fields editable when the output is a PDF. Type: boolean.false

複数レコードのデータ形状​

のために JSONオブジェクトの配列を使用します(生成されたドキュメントごとに1つのオブジェクト)。

[
{ "name": "Alice", "email": "[email protected]" },
{ "name": "Bob", "email": "[email protected]" }
]

のために XMLテンプレートが繰り返し行に期待する構造を使用します(メールマージと同じ考え方です)。 API チェックするのは JSON 解析処理を行い、エンジンが生成されるドキュメントの数を決定します。

API 応答(郵便配達人)​

JSONは多くの場合、次のような形式です。

{
"outputDocuments": [
{
"fileName": "document1.pdf",
"streamFile": "<base64>"
}
]
}

フィールド名は次のように表示される場合もあります。 fileContent、 content、 または data. それぞれを解読します Base64 各ファイルを保存する文字列。

サンプルペイロード​

1. Wordテンプレート(base64)+ JSON 配列(テキスト)→複数 PDFs​

{
"templateFileType": "Docx",
"templateFileName": "template.docx",
"templateFileData": "UEsDBBQAAAAI...",
"documentDataType": "Json",
"documentDataText": "[{\"name\": \"Alice\", \"email\": \"[email protected]\"}, {\"name\": \"Bob\", \"email\": \"[email protected]\"}]",
"outputType": "PDF",
"KeepPdfEditable": false,
"IsAsync": true
}

2. Wordテンプレート(URL)+ JSON データ (URL) → PDFs​

{
"templateFileType": "Docx",
"templateFileName": "template.docx",
"templateFileData": "https://example.com/template.docx",
"documentDataType": "Json",
"documentDataFile": "https://example.com/customers.json",
"outputType": "PDF",
"IsAsync": true
}

3. Wordテンプレート(base64)+ JSON ファイル(base64)→ Excel(xlsx)​

{
"templateFileType": "Docx",
"templateFileName": "template.docx",
"templateFileData": "UEsDBBQAAAAI...",
"documentDataType": "Json",
"documentDataFile": "W3sibmFtZSI6ICJBbGljZSJ9LCB7Im5hbWUiOiAiQm9iIn1d",
"outputType": "xlsx",
"IsAsync": true
}

(documentDataFile = base64 [{"name":"Alice"},{"name":"Bob"}])

4. HTML テンプレート(base64)+ JSON 配列(テキスト)→ HTML​

{
"templateFileType": "HTML",
"templateFileName": "template.html",
"templateFileData": "PCFET0NUWVBFIGh0bWw+...",
"documentDataType": "Json",
"documentDataText": "[{\"title\": \"Invoice 1\", \"heading\": \"Hello\", \"content\": \"A\"}, {\"title\": \"Invoice 2\", \"heading\": \"Hi\", \"content\": \"B\"}]",
"outputType": "HTML",
"IsAsync": true
}

5. PDF テンプレート (URL)+ XML (テキスト)→複数 PDFs​

{
"templateFileType": "PDF",
"templateFileName": "template.pdf",
"templateFileData": "https://example.com/template.pdf",
"documentDataType": "XML",
"documentDataText": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><records><record><name>Alice</name></record><record><name>Bob</name></record></records>",
"outputType": "PDF",
"KeepPdfEditable": true,
"IsAsync": true
}

6. Wordテンプレート(base64)+ XML (URL) → Word (Docx)​

{
"templateFileType": "Docx",
"templateFileName": "template.docx",
"templateFileData": "UEsDBBQAAAAI...",
"documentDataType": "XML",
"documentDataFile": "https://example.com/data.xml",
"outputType": "Docx",
"IsAsync": true
}

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

Array data
Prefer a JSON array in documentDataText when documentDataType is Json and you expect more than one file.
Filename match
Match the extension in templateFileName to templateFileType.
Base64 of file
For D2, base64-encode the whole data file (not each row separately).
Decode response
If the response is JSON, decode each outputDocuments[].streamFile (or fileContent / content / data) from base64.
Endpoint name
Endpoint name is GenerateDocumentMultiple (singular Document), not GenerateDocumentsMultiple.

curlの例​

curl -X POST https://api.pdf4me.com/api/v2/GenerateDocumentMultiple \
-H "Content-Type: application/json" \
-H "Authorization: Basic YOUR_API_KEY" \
-d '{
"templateFileType": "Docx",
"templateFileName": "template.docx",
"templateFileData": "https://example.com/template.docx",
"documentDataType": "Json",
"documentDataText": "[{\"name\":\"Alice\"},{\"name\":\"Bob\"}]",
"outputType": "PDF",
"IsAsync": true
}' \
--output response.json

クイックリファレンス:バリアントごとの必須項目と任意項目​

分野T1+D1T2+D3T1+D2T3+D1PDF出力
templateFileTypeReqReqReqReqReq
templateFileNameReqReqReqReqReq
templateFileDataReq (b64)Req (URL)Req (b64)Req (b64)Req
documentDataTypeReqReqReqReqReq
outputTypeReqReqReqReqReq
documentDataTextReqOmitOmitReqOmit
documentDataFileOmitReqReqOmitOmit
IsAsyncReqReqReqReqReq
KeepPdfEditableOptOptOptN/A*Opt

*以下の場合のみ 出力タイプ は PDF。

コードサンプル​

よくある質問​

How is Multiple different from Single?+
Different endpoint (/api/v2/GenerateDocumentMultiple), fewer template types (Docx, HTML, PDF only), no CSV, can output xlsx, and expects array-shaped data to produce one document per record in a single call.
What does the response look like?+
Typically a JSON object with outputDocuments[], each containing fileName and streamFile (base64). Some responses may use fileContent, content, or data as the field name. Decode each base64 string to save the file.
Which output types are allowed?+
Docx and PDF templates accept PDF, Docx, or xlsx. HTML template accepts HTML only.
Does HTML output produce multiple files?+
Yes when the engine renders one HTML document per input record. The response still uses the outputDocuments[] shape.
What is the maximum array size?+
No published hard cap. Large batches usually push you onto the async path (202 + Location poll). For very large workloads, split into multiple calls of a few hundred records each.
Why is the endpoint name singular Document?+
The path is /api/v2/GenerateDocumentMultiple, not GenerateDocumentsMultiple. A common typo. The plural version returns 404.
Does KeepPdfEditable work for xlsx or HTML output?+
No. It only applies when outputType is PDF. For other outputs the API ignores it.
Can I mix multiple template files in one call?+
No. One call uses one template. To render the same data set against multiple templates, issue one call per template.

関連アクション​

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

ヘルプが必要な場合​