ドキュメント生成(単一)
PDF4me ドキュメント生成(単一) テンプレート (Word、 HTML、 または PDFデータペイロード付き(JSON、 XML、 または CSV1つに REST 呼び出し。テンプレートは Base64公的な URLまたは生 HTMLデータはインラインテキスト、 Base64-エンコードされたファイル、または URLレンダリングされたものを返します PDF、 Docx、 または HTML バイナリ(200)として、または Location-ヘッダー アンケート URL (202)
認証 API リクエスト
毎 PDF4me REST 電話にはあなたの API キー Authorization ヘッダーを基本認証として設定します。開発者ダッシュボードからキーを取得またはローテーションしてください。
終点
/api/v2/GenerateDocumentSingle見逃してはならない重要な事実
ドキュメントデータテキスト または ドキュメントデータファイルドキュメントデータテキスト インライン用 JSON / XML / CSV。 使用 ドキュメントデータファイル のために Base64-エンコードされたデータファイルまたは公開 URL。PDF または Docx. HTML は受け入れます HTML PDFのみ対応 PDF のみ。正確なケースサイズが重要です。IsAsync: true の API 202とLocationヘッダーで応答する場合があります。 GET それ URL (同じ認証)レンダリングされたファイルで200まで(標準) pdf4meAsyncRequest パターン)。HTTP 設定
方法: 役職
URL: https://api.pdf4me.com/api/v2/GenerateDocumentSingle
コンテンツタイプ: アプリケーション/json
承認: 基本 <あなたの PDF4me API キー>
送信 IsAsync: true 体内で。 200 レンダリングされたファイルのバイト列を返します。 202 を返します 位置 アンケート付きのヘッダー URL; GET それ URL 200 まで同じ Authorization ヘッダーを使用します。
変異マトリックス(ポストマン関連)
テンプレートバリアント(T1 / T2 / T3)を1つ、データバリアント(D1 / D2 / D3)を1つ選択してください。6つの組み合わせで、すべての呼び出しに対応できます。
テンプレート (templateFileData)
| コード | ソース | ポストマンの価値 テンプレートファイルデータ | また、必須です。 |
|---|---|---|---|
| T1 | Base64 | Base64 template file (strip data:...;base64, prefix if present) | templateFileName |
| T2 | URL | Full HTTPS URL string (not downloaded by the API request body) | templateFileName |
| T3 | HTML code | Base64-encoded UTF-8 HTML: Buffer.from(html, "utf8").toString("base64") | templateFileName, templateFileType: HTML |
文書データ(2つのうちの1つ) API 分野)
| コード | ソース | APIフィールド | 郵便配達員の価値 |
|---|---|---|---|
| D1 | Text | documentDataText | Raw JSON / XML / CSV string |
| D2 | Base64 | documentDataFile | Base64 of the data file (strip data-URL prefix if present) |
| D3 | URL | documentDataFile | Full HTTPS URL to .json / .xml / .csv |
ルール: ちょうど1つ ドキュメントデータテキスト または ドキュメントデータファイル 設定する必要があります。使用されていないフィールドは本文から除外してください。
一般的な組み合わせ
| # | テンプレート | データ | 典型的な使用例 |
|---|---|---|---|
| 1 | T1 Docx base64 | D1 JSON text | Word mail-merge to PDF |
| 2 | T2 Docx URL | D3 JSON URL | Hosted template + hosted data |
| 3 | T3 HTML | D1 JSON text | HTML mustache rendered to HTML / PDF |
| 4 | T1 PDF form | D2 JSON base64 | PDF template + encoded data file |
| 5 | T2 MailMerge URL | D1 XML text | Word merge fields + inline XML |
templateFileType → 許可された出力タイプ
テンプレートファイルタイプ | 許可された 出力タイプ | 注記 |
|---|---|---|
Docx | PDF, Docx | PDF4me Word template |
MailMerge | PDF, Docx | Mail merge Word |
GoogleDocs | PDF, Docx | Google Docs export style |
HTML | HTML only | Mustache in HTML |
PDF | PDF only | PDF form / template |
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, MailMerge, GoogleDocs |
| 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 string |
| documentDataType | Optional | Format of the data, `Json`, `XML` or `Csv`. | Json, XML, or Csv (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. | With extension, e.g. template.docx, template.html, template.pdf |
| documentDataText | Optional | The data as text. Used when `documentDataFile` is empty. Type: string. | Valid JSON when documentDataType is Json; XML must look like XML; CSV non-empty |
| 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 to data file |
| outputType | Optional | Format of the generated document, e.g. `pdf` or `docx`. Not used by GenerateDocumentSingleV2. | PDF, Docx, or HTML (see allowed-output table above) |
| 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 |
サンプルペイロード
1. Wordテンプレート(base64)+ JSON テキスト → PDF
{
"templateFileType": "Docx",
"templateFileName": "template.docx",
"templateFileData": "UEsDBBQAAAAI...",
"documentDataType": "Json",
"documentDataText": "{\"name\": \"John Doe\", \"email\": \"[email protected]\", \"items\": [{\"product\": \"Widget\", \"price\": 29.99}]}",
"outputType": "PDF",
"KeepPdfEditable": false,
"IsAsync": true
}
2. Wordテンプレート(URL)+ JSON データ (URL) → PDF
{
"templateFileType": "Docx",
"templateFileName": "template.docx",
"templateFileData": "https://example.com/template.docx",
"documentDataType": "Json",
"documentDataFile": "https://example.com/data.json",
"outputType": "PDF",
"KeepPdfEditable": false,
"IsAsync": true
}
3. Wordテンプレート(base64)+ JSON データ(base64)→ワード出力
documentDataFile の base64 を保持します JSON ファイルバイト(解析されたオブジェクトではない)。
{
"templateFileType": "Docx",
"templateFileName": "template.docx",
"templateFileData": "UEsDBBQAAAAI...",
"documentDataType": "Json",
"documentDataFile": "eyJuYW1lIjogIkpvaG4gRG9lIn0=",
"outputType": "Docx",
"IsAsync": true
}
4. HTML テンプレート (base64 の HTML ファイル) + JSON テキスト → HTML
生の HTML Postmanでは、同じペイロードを送信します。 n8n ノードは: base64エンコードされます HTML で templateFileData。
{
"templateFileType": "HTML",
"templateFileName": "template.html",
"templateFileData": "PCFET0NUWVBFIGh0bWw+...",
"documentDataType": "Json",
"documentDataText": "{\"title\": \"Invoice\", \"heading\": \"Hello\", \"content\": \"World\"}",
"outputType": "HTML",
"IsAsync": true
}
5. メールマージ(URL)+ XML テキスト → PDF
{
"templateFileType": "MailMerge",
"templateFileName": "template.docx",
"templateFileData": "https://example.com/template.docx",
"documentDataType": "XML",
"documentDataText": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><root><name>John Doe</name><email>[email protected]</email></root>",
"outputType": "PDF",
"IsAsync": true
}
6. PDF フォームテンプレート(base64)+ CSV テキスト → PDF (編集可能)
{
"templateFileType": "PDF",
"templateFileName": "template.pdf",
"templateFileData": "JVBERi0xLjQKJcfsj6IK...",
"documentDataType": "Csv",
"outputType": "PDF",
"KeepPdfEditable": true,
"IsAsync": true
}
7. Googleドキュメントスタイル(base64)+ JSON URL → Docx
{
"templateFileType": "GoogleDocs",
"templateFileName": "template.docx",
"templateFileData": "UEsDBBQAAAAI...",
"documentDataType": "Json",
"documentDataFile": "https://example.com/data.json",
"outputType": "Docx",
"IsAsync": true
}
郵便配達員の集荷に関するヒント
curlの例
curl -X POST https://api.pdf4me.com/api/v2/GenerateDocumentSingle \
-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",
"documentDataFile": "https://example.com/data.json",
"outputType": "PDF",
"KeepPdfEditable": false,
"IsAsync": true
}' \
--output generated.pdf
クイックリファレンス:バリアントごとの必須項目と任意項目
| 分野 | 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 HTML) | Req |
documentDataType | Req | Req | Req | Req | Req |
outputType | Req | Req | Req | Req | Req |
documentDataText | Req | Omit | Omit | Req | Omit |
documentDataFile | Omit | Req (URL) | Req (b64) | Omit | Omit |
IsAsync | Req | Req | Req | Req | Req |
KeepPdfEditable | Opt | Opt | Opt | N/A* | Opt if PDF |
*KeepPdfEditable 適用条件 出力タイプ は PDF; その API そうでなければ、強制的に誤りを生じさせる。