跳到主要内容

产生 PDF 从 Word 模板 Zapier

本指南涵盖的内容

无需每次都手动填写相同的合同、发票或证书,只需在 Microsoft Word 中设计一次即可。 {{placeholders}} 动态值会流向何处——并让 Zapier + PDF4me 自动填充。每次触发事件发生时(表单提交、新增电子表格行、CRM交易完成), PDF4me 将您的实时数据合并到模板中,并生成最终结果。 PDF 或 Word 文档 只需几秒。无需代码,无需邮件合并插件,无需手册。 PDF 导出。本指南将逐步介绍每个步骤:构建模板、构建数据结构、配置…… Zapier 执行操作,并将输出路由到存储或电子邮件。

工作原理

PDF4me 用途 Mustache 双括号语法 - {{VariableName}} - 内部标准 .docx 文件。您提供数据对象(JSONXML, 或者 CSV) 和 PDF4me 将每个占位符替换为匹配的值,然后将文档渲染为 PDF 或者 DOCX

简单变量{{ClientName}}

已替换为匹配项 JSON 价值

重复行{{#Items}}...{{/Items}}

每个数组项展开一行

条件块{{#ShowDiscount}}...{{/ShowDiscount}}

仅当值为真时,此部分才会显示。

→ 完整语法参考: Word模板语法


步骤 1 - 创建 Word 模板

打开任何 .docx 在 Microsoft Word 文件中,并将每个文档中需要更改的所有值替换为 {{placeholder}}占位符名称是您将在以下内容中匹配的内容: JSON 数据——要简洁、描述性强、前后一致。

典型文档中常用的占位符:

文档类型示例占位符
发票{{ClientName}}{{InvoiceNumber}}{{DueDate}}{{Total}}
合同{{PartyOne}}{{EffectiveDate}}{{Jurisdiction}}{{SignatureDate}}
证书{{RecipientName}}{{CourseName}}{{CompletionDate}}{{IssuedBy}}
录用通知书{{CandidateName}}{{Position}}{{Salary}}{{StartDate}}

简洁模板使用技巧:

  • 在表格单元格、页眉、页脚和文本框中使用占位符 - PDF4me 替换文档中所有对应的文本
  • 保留 .docx 完全按照您希望的输出效果设置样式(字体、颜色、边框) - PDF4me 渲染文档而不改变格式
  • 对于明细表,添加一行数据,内容如下: {{#Items}} 在第一个单元格上和 {{/Items}} 行尾处——循环会自动展开。
带有 Mustache 占位符的 Word 文档模板,用于客户名称、发票号码和项目明细。

一个 Word 模板 {{placeholders}} 在正文、表格单元格和标题中。另存为 .docx 并存储。 Google DriveDropbox, 或者 OneDrive


步骤 2 - 准备文档数据

PDF4me 接受数据 JSON (受到推崇的), XML, 或者 CSV 格式。 JSON 最自然地映射到 Zapier 因为可以直接从字段引用构建对象,所以会触发输出。

极简主义 JSON 示例 - 发票:

{
"ClientName": "Acme Corporation",
"InvoiceNumber": "INV-2026-0042",
"DueDate": "2026-06-15",
"Items": [
{ "Description": "Web design", "Qty": "1", "UnitPrice": "$3,200", "LineTotal": "$3,200" },
{ "Description": "Hosting setup", "Qty": "1", "UnitPrice": "$400", "LineTotal": "$400" }
],
"Subtotal": "$3,600",
"Tax": "$360",
"Total": "$3,960"
}

Zapier你可以构建这个 JSON 使用字符串 代码 Zapier 步骤,或者如果你的触发器是(则直接映射它),则需要执行以下步骤(TypeformJotformGoogle SheetsHubSpot) 已经返回了您需要的字段。

提示: 下载现成的示例数据文件,即可查看具体操作方法。 PDF4me 期望 JSON 先构建结构,然后根据模板中的占位符名称进行调整。

Zapier 操作显示文档数据字段,其中包含从触发器映射的 JSON 数据。

地图 JSON 直接从触发器输出字段获取数据,或粘贴静态数据 JSON 字符串。两种方法都可行——使用 Zap 生成的任何字符串。


步骤 3 - 配置 PDF4me 生成文档操作

添加一个新的操作步骤 Zapier搜索 PDF4me并选择 生成文档使用您的身份验证 PDF4me API 只需输入一次 - Zapier 在您的所有设备上重复使用连接 PDF4me 行动。

操作参数

必需的: 模板文档名称、模板文件、数据格式和文档数据(文本或文件)。输出格式默认为 PDF 如果未设置。

范围必需的它的作用示例值
Template Document NameYesFilename of your Word template including the .docx extension. Map from the filename output of the step that retrieves your template file.invoice-template.docx
Template FileYesBinary content of the .docx template. Map from the file data output of a Google Drive Get File, Dropbox Download File, or OneDrive Get File step.(binary from Google Drive)
Data FormatYesFormat of the data you are supplying. JSON is recommended for Zapier workflows. XML and CSV are also supported.JSON
Data As TextOne of theseThe merge data as a text string - a JSON object, XML document, or CSV content typed or mapped directly in the field. Use this when building JSON from trigger fields in the same Zap.{"ClientName":"Acme","Total":"$3,960"}
Data FileOne of theseBinary data file containing the JSON, XML, or CSV. Use this when a prior Zap step retrieves a data file from cloud storage rather than constructing it inline.(binary from Dropbox)
Output FormatNoFormat of the generated document. PDF produces a tamper-proof, print-ready file. Word (DOCX) produces an editable document. Defaults to PDF.PDF
Output NameNoCustom filename for the generated document. Build it dynamically from trigger fields for organised storage - for example Invoice_{{InvoiceNumber}}.pdf.Invoice_INV-2026-0042.pdf
在 Zapier 中配置 PDF4me 生成文档操作,显示已配置的模板文件、数据格式和文本数据字段。

映射模板二进制文件并将数据格式设置为 JSON粘贴或映射您的 JSON 将数据映射为文本,或将云存储中的文件映射为数据文件。

PDF4me 生成文档操作的输出格式设置为 PDF,输出名称动态配置。

设置输出格式 PDF 对于可直接打印的文件,请使用 Word;对于可编辑的文件,请使用 Word。使用由触发字段生成的动态输出名称。


步骤 4 - 保存或发送输出

PDF4me 操作返回一个 文件 输出——生成的 PDF 或者 DOCX 二进制文件。将其映射到任何下游 Zap 步骤。

云存储

Google Drive 上传文件 Dropbox 上传文件 OneDrive 上传文件 SharePoint 创建文件 - 地图 文件文件内容 并设置动态文件夹路径和文件名。

电子邮件发送

Gmail 发送电子邮件 Outlook 发送电子邮件 - 地图 文件依恋通过触发字段设置收件人地址,以便每个文档自动发送给正确的收件人。

两者兼备——存储和发送

在之后添加这两个步骤。 PDF4me 操作 - 上传到云端硬盘并通过以下方式发送 Gmail 在同一个 Zap 中完成。两个步骤都接收相同的文件输出,无需重复操作。

Zapier Google Drive 上传文件步骤,文件内容映射自 PDF4me 输出和动态文件夹路径

绘制地图 PDF4me 文件 输出到 文件内容 任何存储或电子邮件步骤的字段。根据触发字段动态设置文件夹路径和文件名。

Zapier Gmail 发送电子邮件步骤,其中生成的 PDF 已作为附件发送,收件人电子邮件已从表单触发器映射。

通过映射将生成的文档直接附加到电子邮件中。 文件依恋Gmail 或者 Outlook 发送电子邮件。


完整 Zap Flow

完整的 Zapier 工作流程,包括触发器、PDF4me 生成文档操作和 Google 云端硬盘上传步骤。

完整的 Zap:触发器提供数据 → PDF4me 将其合并到 Word 模板中 → 输出保存到存储和/或通过电子邮件发送。


示例 Zap 流程

示例 Zap 流程Real automation patterns using PDF4me Generate Document with Word templates.
Typeform 提交 → 合同 PDF → 向客户发送电子邮件
  1. Typeform:新增条目 - 收集客户名称、项目范围、开始日期和约定的费用。
  2. 代码 Zapier:构建一个 JSON 来自该物体 Typeform 字段。
  3. Google Drive获取文件 - 检索合同模板 .docx。
  4. PDF4me生成文档 - 合并 JSON 导入模板,输出格式 PDF
  5. Gmail:发送电子邮件 - 附上合同 PDF,通过表单发送到客户的邮箱。
Google Sheets 新行 → 发票 PDF → 保存到云端硬盘 + 通知 Slack
  1. Google Sheets:新行 - 您的计费团队添加的新发票记录会触发 Zap。
  2. Dropbox: 下载文件 - 从共享模板文件夹中检索发票模板 .docx。
  3. PDF4me生成文档 - 将行数据(客户、项目、金额)合并到模板中 JSON
  4. Google Drive上传文件 - 保存发票 PDF 复制到对应的客户端文件夹。
  5. Slack:向 #billing 发送消息 - 发布发票号码和团队的云端硬盘链接。
HubSpot 交易完成 → 录用通知书 DOCX → 上传至 SharePoint
  1. HubSpot交易阶段已更改为“已完成并赢得” - 当销售交易被标记为已赢得时触发。
  2. HubSpot获取联系人 - 检索关联的联系人的姓名、电子邮件和角色。
  3. OneDrive: 获取文件内容 - 检索 offer letter template .docx。
  4. PDF4me生成文档 - 合并联系方式和交易数据;输出格式设置为 Word 以便进一步审核。
  5. SharePoint创建文件 - 保存 DOCX 提交至人事文件夹,以便签字和办理入职手续。

常见问题解答

What placeholder syntax does PDF4me use in Word templates?+
PDF4me uses double curly brace Mustache syntax - {{VariableName}}. Place the placeholder anywhere in the Word document: body text, table cells, headers, footers, or text boxes. The name is case-sensitive and must exactly match the corresponding key in your JSON, XML, or CSV data. For repeating sections like invoice line items, use {{#Items}}...{{/Items}} loop syntax. For conditional sections that only appear when a value is present, use {{#ShowSection}}...{{/ShowSection}}.
What data formats does the Generate Document action accept?+
JSON, XML, and CSV. JSON is recommended because Zapier trigger output fields naturally map to JSON key-value pairs - you can build the JSON string inline using a Code step or directly paste a static object. XML and CSV are useful when your data source already produces those formats. Supply the data either as a text string in the Data As Text field or as a binary file in the Data File field.
Can I output a Word document instead of a PDF?+
Yes. Set Output Format to Word (DOCX) when the generated document needs further editing - for example a contract that goes through a tracked-changes review before signing, or an offer letter that HR wants to personalise before sending. Use PDF when you need a tamper-proof, print-ready output that cannot be accidentally edited after generation.
How do I handle repeating rows like invoice line items?+
In your Word template, add one row in the table with {{#Items}} at the start and {{/Items}} at the end of the row. Inside the row, use placeholders for each column - {{Description}}, {{Qty}}, {{UnitPrice}}, {{LineTotal}}. In your JSON data, supply Items as an array of objects: [{"Description":"Consulting","Qty":"8","UnitPrice":"$150","LineTotal":"$1,200"},{"Description":"Expenses","Qty":"1","UnitPrice":"$80","LineTotal":"$80"}]. PDF4me expands the loop and inserts a row for each array item automatically.
Where should I store the Word template so Zapier can access it?+
Store it in any cloud service Zapier can connect to - Google Drive, Dropbox, OneDrive, or SharePoint. Before the PDF4me Generate Document action, add a Get File step from the same service to download the binary content. Map the file binary into Template File and the filename into Template Document Name. The template stays in one place; every Zap run reads the latest version automatically - update the template once and all future documents use the new design.

相关指南

获取帮助