文書を生成する(複数)
PDF4me 文書を生成する(複数) 複数のドキュメントを一度にレンダリングします REST 電話。単語を1つ送信します。 HTML、 または PDF テンプレート (Base64、 URLまたは生 HTML)とレコードの配列(JSON または XMLテキストとして、 Base64 ファイル、または URL) を返します。 JSON 生成されたファイルのリスト(レコードごとに1エントリ) Base64 で outputDocuments[].streamFileまたは、応答に応じて単一のバイナリ値。
認証 API リクエスト
毎 PDF4me REST 電話にはあなたの API キー Authorization ヘッダーを基本認証として設定します。開発者ダッシュボードからキーを取得またはローテーションしてください。
終点
/api/v2/GenerateDocumentMultipleエンドポイント名は ドキュメントを複数生成する (単数形) 書類)、 ない 複数のドキュメントを生成する。
見逃してはならない重要な事実
outputDocuments[]ファイル名 そしてbase64 ストリームファイル (時々 ファイルコンテンツ、 コンテンツ、 または データ各base64文字列をデコードしてファイルを保存します。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 |
| templateFileType | Docx, HTML, PDF only | Also MailMerge, GoogleDocs |
| documentDataType | Json, XML only | Also Csv |
| outputType | PDF, Docx, xlsx (Word/PDF), HTML | No xlsx |
| Data shape | Typically array of records (one doc per row) | Usually one object |
| outputFileName | Integration-UI only (output naming) | Not in API body either |
変異マトリックス(ポストマン関連)
テンプレート (templateFileData)
| コード | ソース | 郵便配達員の価値 | また、必須です。 |
|---|---|---|---|
| T1 | Base64 | Base64 template (strip data:...;base64, prefix if present) | templateFileName |
| T2 | URL | HTTPS URL string | templateFileName |
| T3 | HTML code | Base64(UTF-8 HTML): Buffer.from(html, "utf8").toString("base64") | templateFileName, templateFileType: HTML |
文書データ
| コード | ソース | APIフィールド | 郵便配達員の価値 |
|---|---|---|---|
| D1 | Text | documentDataText | JSON array (or XML with multiple records) |
| D2 | Base64 | documentDataFile | Base64 of the .json / .xml file |
| D3 | URL | documentDataFile | URL to the data file |
どちらかを使用してください ドキュメントデータテキスト または ドキュメントデータファイル (使用しないフィールドは省略してください。)
templateFileType → 許可された出力タイプ
テンプレートファイルタイプ | 許可された 出力タイプ |
|---|---|
Docx | PDF, Docx, xlsx |
PDF | PDF, Docx, xlsx |
HTML | HTML only |
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 |
| templateFileType | Optional | Type of the template file, e.g. `Docx`, `Html` or `Pdf`. Not used by GenerateDocumentSingleV2. | Docx, HTML, PDF |
| templateFileData | Optional | Required. 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 |
| documentDataType | Optional | Format of the data, `Json`, `XML` or `Csv`. | Json or XML (exact casing) |
| templateFileName | Optional | Required. 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 |
| documentDataText | Optional | The data as text. Used when `documentDataFile` is empty. Type: string. | Valid JSON (JSON.parse) or XML-like for XML |
| documentDataFile | Optional | The 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 |
| outputType | Optional | Format of the generated document, e.g. `pdf` or `docx`. Not used by GenerateDocumentSingleV2. | PDF, Docx, xlsx, or HTML |
| metaDataJson | Optional | Optional document metadata as a JSON string. Type: string. | |
| keepPdfEditable | Optional | Keep form fields editable when the output is a PDF. Type: boolean. | false |
複数レコードのデータ形状
のために JSONオブジェクトの配列を使用します(生成されたドキュメントごとに1つのオブジェクト)。
[
]
のために 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
}
郵便配達員の集荷に関するヒント
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+D1 | T2+D3 | T1+D2 | T3+D1 | PDF出力 |
|---|---|---|---|---|---|
templateFileType | Req | Req | Req | Req | Req |
templateFileName | Req | Req | Req | Req | Req |
templateFileData | Req (b64) | Req (URL) | Req (b64) | Req (b64) | Req |
documentDataType | Req | Req | Req | Req | Req |
outputType | Req | Req | Req | Req | Req |
documentDataText | Req | Omit | Omit | Req | Omit |
documentDataFile | Omit | Req | Req | Omit | Omit |
IsAsync | Req | Req | Req | Req | Req |
KeepPdfEditable | Opt | Opt | Opt | N/A* | Opt |
*以下の場合のみ 出力タイプ は PDF。