ドキュメントを生成する(複数) n8n
複数のドキュメントを生成する これはn8nのPDF4meノードアクションで、ノード内では「Generate Documents (Multiple)」と表示されます。単一のテンプレートとレコードの配列から、一度に複数の完成ファイルを生成します。請求書、顧客向けレター、地域別レポートなどのバッチ処理に使用でき、各ドキュメントは個別のn8nアイテムとして返されます。
このノードの機能
PDF4me: 文書を生成する(複数) 1つのテンプレートとレコードのリストを受け取り、1つのツールで多数の完成文書を生成します。 n8n 実行します。 言葉、 HTML、 または PDF テンプレート バイナリデータを介して、 Base64、 HTML コード、または URL プラス 大量のデータとして JSON または XML (レコードの配列または繰り返し) XML生成された各ファイルは個別の出力項目として返されるため、ループ、保存、メール送信、または個別にアップロードできます。このノードを代わりに使用してください。 ドキュメント生成(単一) 顧客リスト、請求書リスト、またはレコードリストがあり、1回の実行で各行ごとに完成したドキュメントを1つ作成したい場合。
認証 API リクエスト
毎 PDF4me ノード n8n 有効な 接続するための認証情報. 作成または選択して、 PDF4me API ワークフローがバッチ文書生成リクエストを安全に認証できるようにするためのキー。
見逃してはならない重要な事実
/generate-documents-multiple-full.png)
フルノードパネル。Wordテンプレート+ JSON テキストデータ + PDF 出力は典型的なメールマージの設定です
ドキュメント生成(複数) vs ドキュメント生成(単一)
このタスクで最もよくある間違いは、2つのうちどちらかを間違えることです。どちらを選ぶかは、返ってくるファイルの数と、提供されるテンプレートやデータ形式によって決まります。
| 側面 | 文書を生成する(複数) | ドキュメント生成(単一) |
|---|---|---|
| Files returned | Many, one n8n item per generated document | Exactly one |
| Template types | Word, HTML, PDF | Word, HTML, PDF, plus Mail Merge and Google Docs |
| Data formats | JSON or XML only | JSON, XML, and CSV |
| Output types | PDF, Word, or Excel (HTML templates output HTML) | PDF, Word (no Excel option) |
| Reach for it when | You have a list of records and want one document per row | You have a single record, CSV data, or a Mail Merge template |
ドキュメント生成(複数)に必要なパラメータは何ですか?
必須 n8n UI: 接続に使用する認証情報、テンプレートファイルタイプ、テンプレートファイル入力タイプ、ドキュメントデータタイプ、ドキュメントデータ入力タイプ、および出力タイプ(常に表示されます。選択肢はテンプレートファイルタイプによって異なります)。条件付き必須フィールド(テンプレートバイナリプロパティ、テンプレート Base64 コンテンツ、 HTML コード、テンプレートファイル URL(ドキュメントデータテキスト、ドキュメントバイナリプロパティなど)は、親の入力タイプが選択されている場合にのみ表示されます。出力ファイル名、保持 PDF 編集可能かどうか、およびバイナリデータ出力名はオプションであり、適切なデフォルト値が設定されています。
| パラメータ | 必須 | その機能 | 例 |
|---|---|---|---|
| Template File Type | Required | Select the Template file type. Options: Word, HTML, PDF. Default is `Word`. | Word |
| Output Type | Conditional | Format of the generated documents. Shown when Template File Type is Word. Options: PDF, Word, Excel. Default is `PDF`. | PDF |
| Output File Name | Conditional | Name for the generated files, without extension (the Output Type extension is added). When several documents are generated, `_1`, `_2` and so on is appended (for example `document_1.pdf`). If empty, the names returned by PDF4me are used, or `generated_document`. Shown when Output Type is PDF. | _1 |
| Keep PDF Editable | Conditional | Whether to keep the generated PDF form fields editable. Shown when Output Type is PDF. Default is `No`. | No |
| Output File Name | Conditional | Name for the generated files, without extension (the Output Type extension is added). When several documents are generated, `_1`, `_2` and so on is appended (for example `document_1.pdf`). If empty, the names returned by PDF4me are used, or `generated_document`. Shown when Output Type is Word. | _1 |
| Output File Name | Conditional | Name for the generated files, without extension (the Output Type extension is added). When several documents are generated, `_1`, `_2` and so on is appended (for example `document_1.pdf`). If empty, the names returned by PDF4me are used, or `generated_document`. Shown when Output Type is Excel. | _1 |
| Output Type | Conditional | Format of the generated documents. Shown when Template File Type is HTML. Options: HTML. Default is `HTML`. | HTML |
| Output File Name | Conditional | Name for the generated files, without extension (the Output Type extension is added). When several documents are generated, `_1`, `_2` and so on is appended (for example `document_1.pdf`). If empty, the names returned by PDF4me are used, or `generated_document`. Shown when Output Type is HTML. | _1 |
| Output Type | Conditional | Format of the generated documents. Shown when Template File Type is PDF. Options: PDF, Word, Excel. Default is `PDF`. | PDF |
| Output File Name | Conditional | Name for the generated files, without extension (the Output Type extension is added). When several documents are generated, `_1`, `_2` and so on is appended (for example `document_1.pdf`). If empty, the names returned by PDF4me are used, or `generated_document`. Shown when Output Type is PDF. | _1 |
| Keep PDF Editable | Conditional | Whether to keep the generated PDF form fields editable. Shown when Output Type is PDF. Default is `No`. | No |
| Output File Name | Conditional | Name for the generated files, without extension (the Output Type extension is added). When several documents are generated, `_1`, `_2` and so on is appended (for example `document_1.pdf`). If empty, the names returned by PDF4me are used, or `generated_document`. Shown when Output Type is Word. | _1 |
| Output File Name | Conditional | Name for the generated files, without extension (the Output Type extension is added). When several documents are generated, `_1`, `_2` and so on is appended (for example `document_1.pdf`). If empty, the names returned by PDF4me are used, or `generated_document`. Shown when Output Type is Excel. | _1 |
| Template File Input Type | Required | How to provide the template file. Options: Binary Data, Base64 String, HTML Code, URL. Default is `Binary Data`. | Binary Data |
| Template Binary Property | Conditional | Name of the binary property containing the template file. Shown when Template File Input Type is Binary Data. Default is `data`. | data |
| Template File Name | Conditional | Name of the template file (including extension). If empty, the file name of the binary data is used. Shown when Template File Input Type is Binary Data. | template.docx |
| Template File Name | Conditional | Name of the template file (including extension). If empty, the file name of the binary data is used. Shown when Template File Input Type is Binary Data. | template.docx |
| Template File Name | Conditional | Name of the template file (including extension). If empty, the file name of the binary data is used. Shown when Template File Input Type is Binary Data. | template.docx |
| Template Base64 Content | Conditional | Base64 encoded template file content. Shown when Template File Input Type is Base64 String. | UEsDBBQAAAAI... |
| Template File Name | Conditional | Name of the template file (including extension). Shown when Template File Input Type is Base64 String. | template.docx |
| Template File Name | Conditional | Name of the template file (including extension). Shown when Template File Input Type is Base64 String. | template.docx |
| Template File Name | Conditional | Name of the template file (including extension). Shown when Template File Input Type is Base64 String. | template.docx |
| Template File Name | Conditional | Name of the template file (including extension). Shown when Template File Input Type is HTML Code. | template.docx |
| Template File Name | Conditional | Name of the template file (including extension). Shown when Template File Input Type is HTML Code. | template.docx |
| Template File Name | Conditional | Name of the template file (including extension). Shown when Template File Input Type is HTML Code. | template.docx |
| HTML Code | Conditional | Write your HTML template code here. It will be automatically converted to base64. Shown when Template File Input Type is HTML Code. | <h1>{{title}}</h1> |
| Template File Name | Conditional | Name of the template file (including extension). Shown when Template File Input Type is URL. | template.docx |
| Template File Name | Conditional | Name of the template file (including extension). Shown when Template File Input Type is URL. | template.docx |
| Template File Name | Conditional | Name of the template file (including extension). Shown when Template File Input Type is URL. | template.docx |
| Template File URL | Conditional | URL of the template file. Shown when Template File Input Type is URL. | https://example.com/template.docx |
| Template File URL | Conditional | URL of the template file. Shown when Template File Input Type is URL. | https://example.com/template.docx |
| Template File URL | Conditional | URL of the template file. Shown when Template File Input Type is URL. | https://example.com/template.docx |
| Document Data Type | Required | The data type for the template. Options: JSON, XML. Default is `JSON`. | JSON |
| Document Data Input Type | Required | How to provide the document data. Options: Text, Binary Data, Base64 String, URL. Default is `Text`. | Text |
| Document Data Text | Conditional | JSON or XML data to fill the template with, matching Document Data Type. Shown when Document Data Input Type is Text. | [{"name":"Alice"},{"name":"Bob"}] |
| Document Data Text | Conditional | JSON or XML data to fill the template with, matching Document Data Type. Shown when Document Data Input Type is Text. | [{"name":"Alice"},{"name":"Bob"}] |
| Document Binary Property | Conditional | Name of the binary property containing the data file. Shown when Document Data Input Type is Binary Data. Default is `data`. | data |
| Document Data File Name | Conditional | Name of the data file (including extension), used when the file is uploaded to PDF4me. If empty, the file name of the binary data is used. Shown when Document Data Input Type is Binary Data. | customers.json |
| Document Data File Name | Conditional | Name of the data file (including extension), used when the file is uploaded to PDF4me. If empty, the file name of the binary data is used. Shown when Document Data Input Type is Binary Data. | customers.json |
| Document Base64 Content | Conditional | Base64 encoded data file content. Shown when Document Data Input Type is Base64 String. | W3sibmFtZSI6... |
| Document Data File Name | Conditional | Name of the data file (including extension). Not used: the node does not send this value to PDF4me. Shown when Document Data Input Type is Base64 String. | customers.json |
| Document Data File Name | Conditional | Name of the data file (including extension). Not used: the node does not send this value to PDF4me. Shown when Document Data Input Type is Base64 String. | customers.json |
| Document Data File Name | Conditional | Name of the data file (including extension). Not used: the node does not send this value to PDF4me. Shown when Document Data Input Type is URL. | customers.json |
| Document Data File Name | Conditional | Name of the data file (including extension). Not used: the node does not send this value to PDF4me. Shown when Document Data Input Type is URL. | customers.json |
| Document Data File URL | Conditional | URL of the data file. Shown when Document Data Input Type is URL. | https://example.com/customers.json |
| Document Data File URL | Conditional | URL of the data file. Shown when Document Data Input Type is URL. | https://example.com/customers.json |
| Binary Data Output Name | Optional | Custom name for the binary data in n8n output. Default is `data`. | data |
テンプレートファイルタイプのオプション
テンプレートの形式を選択してください。この選択によって出力タイプの選択肢が変わります。
/generate-documents-multiple-template-file-type.png)
テンプレートファイルタイプのドロップダウン。Word、 HTML、 または PDF (ここではメールマージやGoogleドキュメントは使用しません)
言葉デフォルト: .docx テンプレートHTMLHTML テンプレートを貼り付けました HTML コードPDFPDF テンプレートテンプレートファイル入力タイプのオプション
テンプレートをノードに挿入する方法を選択してください。この選択によって、後続のフィールドが変更されます。
/generate-documents-multiple-template-file-input-type.png)
テンプレートファイル入力タイプ。バイナリデータ、 Base64 弦、 HTML コード、または URL
バイナリデータデフォルト: 前のノードからのファイルテンプレートバイナリプロパティ バイナリフィールド名(デフォルト) データ) テンプレートファイル名 オプションであり、指定された場合はアップロードされたファイル名が使用されます。Base64文字列Base64-エンコードされたテンプレートテンプレートのBase64コンテンツ。 テンプレートファイル名 拡張子がテンプレートファイルの種類(.docx、.html、.pdf)と一致するように、この設定が必要です。HTMLコードペースト生 HTML 列をなして (HTML のみ){{タイトル}}、 {{コンテンツ}} の中へ HTMLコードノードはそれを基本的な <html> 欠落している場合はシェルを装備してください。 テンプレートファイル名 必須です (例: テンプレート.html)URL公開リンクからダウンロードテンプレートファイルのURL。 PDF4me テンプレートを直接取得します。 URL オープン(認証なし)で テンプレートファイル名 拡張子がテンプレートタイプと一致するように、これは必須です。ドキュメントデータタイプのオプション
送信するデータ形式を選択してください。
/generate-documents-multiple-document-data-type.png)
文書データ型。 JSON または XML (いいえ CSV この作戦において)
JSONデフォルト:レコードの配列(最も一般的)[{"name":"Alice"}, {"name":"Bob"}]ノードはペイロードの解析結果を検証します。単一のオブジェクトは1つのドキュメントを生成します。複数のドキュメントが必要な場合は配列を渡してください。XML繰り返しレコード XMLドキュメントデータ入力タイプのオプション
バルクデータがノードに入力される方法を選択してください。
/generate-documents-multiple-document-data-input-type.png)
ドキュメントデータ入力タイプ。テキスト、バイナリデータ、 Base64 文字列、または URL
文章デフォルト: 大量のデータをインラインで貼り付ける文書データテキストこのフィールドは、テキストを選択した場合の複数操作において必須です(単一の場合よりも厳格です)。バイナリデータ前のノードのデータファイルを使用する文書バイナリプロパティ バイナリフィールド名(デフォルト) データテンプレートとデータバイナリのプロパティ名が同じアイテムから取得されている場合、両者が衝突しないように注意してください。Base64文字列Base64エンコードされたデータファイル.json または .xml ファイルをbase64として ドキュメントのBase64コンテンツ。 ドキュメントデータファイル名 が必要です。URL公開リンクからダウンロードドキュメントデータファイルのURL 公衆に HTTPS URL の JSON または XML データファイル。 ドキュメントデータファイル名 拡張子がデータ型と一致するように、これは必須です。出力フィールド
成功したランは1 n8n 生成されたドキュメントごとに1つのアイテム。各アイテムには、 JSON メタデータとバイナリファイル。
出力
ノードが返すフィールド。
| 分野 | タイプ | 内容物 |
|---|---|---|
fileName | String | File name of the resulting file. |
mimeType | String | MIME type of the resulting file, for example `application/pdf`. |
fileSize | Number | Size of the resulting file in bytes. |
success | Boolean | True when the operation succeeded. |
documentIndex | String | Position of this document among the generated documents, starting at 1. |
totalDocuments | Number | Number of documents in PDF4me's response. |
data | Binary | One generated document per output item, in the chosen Output Type. If PDF4me returns a single file instead of a list, it is stored in the property `data` whatever Binary Data Output Name says. |
n8nで複数のドキュメントを生成する設定方法を教えてください。
- 追加 PDF4me あなたの n8n ワークフローを設定します。 リソース に 生成する そして 操作の生成 に 文書を生成する(複数)。
- で 接続するための認証情報選択してください PDF4me 認証情報またはクリック 新しい認証情報を作成する そしてあなたの API 鍵。
- セット テンプレートファイルの種類 に 言葉 (デフォルト)、 HTML、 または PDF。
- セット 出力タイプ。 PDFWord、またはExcel for Word / PDF テンプレート; HTML のみ HTML テンプレート。
- セット テンプレートファイル入力タイプ に バイナリデータ (デフォルト)、 Base64 弦、 HTML コード (HTML のみ)、または URL そして、一致するテンプレートフィールドに加えて テンプレートファイル名 必要に応じて。
- セット 文書データタイプ に JSON (デフォルト)または XML。
- セット ドキュメントデータ入力タイプ に 文章 (デフォルト)そしてあなたの JSON 配列を 文書データテキストまたはバイナリデータを選択します。 Base64 文字列、または URL データファイルを提供してください。
- セット 出力ファイル名 読みやすいものに
invoiceファイルは次のように返されますinvoice_1.pdf、invoice_2.pdf、... - 出力する場合 PDF テンプレートにフォーム フィールドがある場合は、 保つ PDF 編集可能。
- 離れる バイナリデータ出力名 として
data下流ノードで別のプロパティ名が必要な場合を除きます。ノードを実行し、複数の出力項目を「バッチ分割」、「バイナリファイル書き込み」、「メール送信」、または「クラウドストレージアップロード」にルーティングします。
典型的な構成
ワークフローの例Common n8n workflow patterns using Generate Documents (Multiple).
- Google Sheetsノードは、顧客の名前、住所、残高を含む顧客リストをワークフローに取り込みます。
- コードまたはセットノードは行をパッケージ化します JSON オブジェクトの配列(顧客ごとに1つのオブジェクト)。
- PDF4me テンプレートファイルタイプ Word、出力タイプでドキュメント生成(複数)を実行します PDFテンプレートファイル入力タイプはバイナリデータ、ドキュメントデータ入力タイプはテキストです。出力ファイル名は
顧客への手紙。 - このノードは、顧客ごとに 1 つのアイテムを返します。
customer_letter_1.pdf、customer_letter_2.pdf、 等々。 - ループオーバーアイテムノードは各アイテムを送信します PDF 該当する顧客にGmail経由で送信するか、Googleドライブにアップロードします。
- 一方のノードが.docxテンプレートをダウンロードし、もう一方のノードが.json形式の顧客ファイルをダウンロードします。マージノードがこれらを結合し、両方のバイナリファイルを1つのアイテムに格納します。
- PDF4me ドキュメント生成(複数)は、テンプレートファイル入力タイプバイナリデータ(
テンプレートバイナリプロパティテンプレートフィールド名に設定)およびドキュメントデータ入力タイプバイナリデータ(文書バイナリプロパティデータフィールド名に設定します。 - セット
ドキュメントデータファイル名データファイルに名前が付けられていない場合data.json。 - 生成されたファイルは個別のアイテムとして返され、 SharePoint 顧客IDにちなんで名付けられたドキュメントライブラリ。
- 毎晩実行されるスケジュールトリガーによって、請求書バッチ処理が実行されます。
- PDF4me 「ドキュメント生成(複数)」は「テンプレートファイル入力タイプ」に設定されています。 URL (
テンプレートファイルのURLS3 上の .docx 請求書テンプレートとドキュメント データ入力タイプを指します URL (ドキュメントデータファイルのURL生成されたものを指すbilling-cycle.jsonファイル)。 テンプレートファイル名はinvoice.docxそしてドキュメントデータファイル名はbilling-cycle.json。- 出力タイプは PDF出力ファイル名は
請求書、そしてキープ PDF 編集可能はオフになっています。 - 返品された商品はすべて、Dropbox内の顧客フォルダにアップロードされ、Outlook経由でメールで送信されます。
- Webhookトリガーは、マーケティングキャンペーンが開始されたときに作動します。
- PDF4me 「ドキュメントの生成(複数)」はテンプレートファイルタイプで設定されています。 HTML テンプレートファイル入力タイプ HTML コード。 HTML ヒゲのプレースホルダーが付いたノードに直接貼り付けられます。
- ドキュメントデータ型は JSONドキュメント データ入力タイプはテキストで、式はキャンペーンのリード リストを JSON 配列。
- 出力タイプは HTMLノードは1つを返します HTML リードごとにファイルを作成。
- Write Binary Fileノードは、生成された各バイナリファイルを保存します。 HTML パブリックウェブフォルダにリンクを送信し、別のノードが各リードにパーソナライズされたリンクを送信します。
- 日次スケジュールトリガーは、PostgreSQLからKPIの数値を取得します。
- Setノードは行を領域ごとにグループ化します。 JSON 配列、地域ごとに1レコード。
- PDF4me テンプレートファイルタイプ Word、出力タイプ Excel、ドキュメントデータタイプを指定してドキュメントを生成する (複数) JSONドキュメントデータ入力タイプはテキストです。出力ファイル名は
地域レポート。 - このノードは、名前の付いた領域ごとに 1 つの .xlsx ファイルを返します。
region_report_1.xlsx、region_report_2.xlsx、 等々。 - Microsoft OneDriveノードは、各ファイルを分析チーム用の対応するリージョンフォルダにアップロードします。
実践的なヒント
チートシート
| 分野 | 価値 |
|---|---|
| Resource | Generate |
| Operation | Generate Documents (Multiple) |
| Template File Type | Word |
| Output Type | PDF |
| Template File Input Type | Binary Data |
| Template Binary Property | data |
| Document Data Type | JSON |
| Document Data Input Type | Text |
| Document Data Text | (bulk JSON array with multiple records) |
| Output File Name | my_document (optional, becomes prefix) |
| Binary Data Output Name | data |
| Credentials | PDF4me API credential |
よくある質問
関連アクション
他のプラットフォームでの同じタスク
POST /api/v2/GenerateDocumentMultiple エンドポイント。カスタムバックエンドコードまたはPostmanテスト用。