AI文档解析器使用解析器
本指南涵盖的内容
AI文档解析器。解析 是将 JSON 转换为 JSON 的仪表板设置。 文档模式 进入 人工智能驱动的结构化PDF提取你创建了一个 分析器选择 解析 输入类型,并描述您想要的字段。 字段名, 字段类型, 和 字段描述AI 会按语义读取文档,因此无需绘制捕获区域或使用正则表达式。保存后,相同的分析器 ID 将从文档中运行。 REST API, Make, Zapier, Power Automate, 和 n8n。
验证您的设置
AI文档解析器分析器是在以下环境中创建的: PDF4me 开发者控制面板。使用您的帐户登录,然后创建或复制一个 API AI解析器的关键 API 调用引用您在此处构建的分析器的函数。
- 分析器列表(步骤 1–2):
https://dev.pdf4me.com/dashboard/#/ai-document-parser/ - 分析器详细信息(步骤 3–5):
https://dev.pdf4me.com/ai-document-parser/?id=<analyzer-guid>
您不容错过的重要事实
字段描述 用于查找文档中每个值的字符串。请尽可能具体,并包含别名(例如“销售订单号,有时也写作 SO No.”)。模糊的描述会降低提取质量。采购订单解析器)是每个 API 呼叫和自动化模块的使用。请预先选择清晰的命名规则;之后更改命名规则意味着需要重新配置所有指向该模块的工作流程。步骤 1:在控制面板中打开 AI 文档解析器
- 登录 dev.pdf4me.com。
- 从仪表盘侧边栏点击 AI文档解析器。
- 列表页面显示所有现有的分析器,包含三列: 分析器 ID, 分析器类型 (解析或分类),以及 行动。
- 点击蓝色 + 添加 按下按钮即可启动新的分析器。

AI文档解析器列表视图。点击“+添加”创建新的分析器。
步骤 2:选择分析器类型“解析”并为其命名
新行出现,包含三个控件:
- 分析器 ID 输入输入任何你能记住的清晰标识符,例如
purchase order parser,Invoice Parser v1, 或者vendor_statement_parser命名格式没有限制。蛇形命名法、驼峰命名法、烤肉串命名法、带空格的普通单词,都一样有效。 - 分析器类型下拉菜单。 挑选 解析 (本指南)或 分类 (参见) 分类指南)。
- 保存/取消 按钮。“保存”按钮用于创建分析器;“取消”按钮用于放弃该行。

添加行:输入分析器 ID,选择解析,然后保存。
命名小贴士: 在名称中包含文档系列(发票解析器, 采购订单解析器, 发货单解析器分析器 ID 是下游自动化程序调用的名称;每次将其连接到新平台时,使用清晰的名称都至关重要。任何命名规则或分隔符样式均可。
步骤 3:打开分析器并添加架构
点击新行即可打开详情页面。URL 格式如下:
https://dev.pdf4me.com/ai-document-parser/?id=<your-analyzer-guid>
仪表盘会在您首次打开分析器时生成一个 GUID。将此 URL 添加到书签,以便下次直接跳转到同一个分析器。
详情页面显示:
- 解析信息 (左图)显示您在步骤 2 中输入的分析器 ID。此面板为只读面板。
- 模式 (右)默认为空。点击 + 点击右上角的按钮添加架构。
- 保存更改 (左上角)保存您对此页面所做的任何编辑。
- 后退返回到 分析器列表。

分析器详情。点击蓝色“+”按钮添加文档架构。
步骤 4:定义文档模式 JSON
点击后 +一个空白的架构卡片打开。粘贴一个 JSON 具有两个顶级键的对象:
description用一句话概括模式提取的内容。人工智能会将此作为整体上下文。fields字段定义数组。每个字段包含:fieldName机器可读名称(不含空格),用作 JSON 答案中的关键点。fieldType。string,number, 或者date驱动解析和验证。fieldDescription人工智能用于查找此字段的自然语言提示。请具体说明。

带有发票和采购订单模板快速填充按钮的文档架构编辑器。
示例:采购订单模式
{
"description": "Extracting data from purchase orders and sales orders.",
"fields": [
{
"fieldName": "SalesOrderNumber",
"fieldType": "string",
"fieldDescription": "Sales Order Number"
},
{
"fieldName": "AgentName",
"fieldType": "string",
"fieldDescription": "Name of the agent, mostly given as Agent Name."
},
{
"fieldName": "DeptCode",
"fieldType": "string",
"fieldDescription": "Department or cost-centre code printed on the order."
},
{
"fieldName": "OrderDate",
"fieldType": "date",
"fieldDescription": "Date the order was placed. Accept formats like DD/MM/YYYY, MM-DD-YYYY, or written out as 5 June 2026."
},
{
"fieldName": "TotalAmount",
"fieldType": "number",
"fieldDescription": "Grand total of the order in the document's currency, after taxes."
}
]
}
示例:发票模板(使用“发票快速填充”按钮)
{
"description": "Extracting data from supplier invoices.",
"fields": [
{
"fieldName": "InvoiceNumber",
"fieldType": "string",
"fieldDescription": "Unique invoice identifier, sometimes shown as Invoice No. or INV."
},
{
"fieldName": "InvoiceDate",
"fieldType": "date",
"fieldDescription": "Date the invoice was issued."
},
{
"fieldName": "DueDate",
"fieldType": "date",
"fieldDescription": "Date payment is due, sometimes shown as Payment Due or Net Due."
},
{
"fieldName": "VendorName",
"fieldType": "string",
"fieldDescription": "Company name of the supplier or vendor sending the invoice."
},
{
"fieldName": "TotalAmount",
"fieldType": "number",
"fieldDescription": "Grand total in the invoice currency, including taxes."
}
]
}
快速填写按钮(发票、采购订单): 在架构卡的底部。 将它们作为起点 只需单击其中一个即可加载该文档系列的典型架构,然后重命名、精简或扩展字段以匹配您的实际文档。这些预设只是框架,并非最终架构。
包含表字段的模式(嵌套行)
使用 字段类型:"表格" 当您需要提取重复行(例如发票明细或采购订单明细)时,每个表字段都有其自身的嵌套结构。 字段 描述列的数组。
{
"description": "Invoice data extractor",
"fields": [
{
"fieldName": "invoiceNumber",
"fieldType": "string",
"fieldDescription": "Invoice number / bill number / receipt number"
},
{
"fieldName": "invoiceDate",
"fieldType": "date",
"fieldDescription": "Look for labels: 'Invoice Date', 'Bill Date', 'Date', 'Dated', 'Issue Date', 'Doc Date'. If 4 digit year not found then consider 2 digit year at the end of extracted date.",
"fieldMethod": "generate"
},
{
"fieldName": "lineItems",
"fieldType": "table",
"fieldDescription": "All product / service rows from the invoice table. Be careful, sometimes a row can be part of the next item like when description goes over one line, but it's of a single item.",
"fields": [
{
"fieldName": "itemNumber",
"fieldType": "string",
"fieldDescription": "Product number, product id number or product code"
},
{
"fieldName": "hsnCode",
"fieldType": "string",
"fieldDescription": "HSN / SAC code (4 to 8 digit)"
}
]
}
]
}
字段属性
| 属性 | 必需的? | 它的作用 |
|---|---|---|
fieldName | Required | The name of the field and how it will appear in the response JSON. |
fieldType | Required | The type of data to extract. One of string, number, date, or table. |
fieldDescription | Required | Natural-language description of what needs to be extracted and where to find it. Include alternate labels and example formats so the AI matches correctly. |
fieldMethod | Optional (default extract) | How the AI fills the value. extract takes the value verbatim from the document. generate tells the AI to derive or normalise it (useful for dates, computed totals, or cleaned-up IDs). Omit for default extract behaviour. |
fields | Required when fieldType is table | Nested array describing the columns of the table. Each entry takes the same attributes as a top-level field (fieldName, fieldType, fieldDescription, fieldMethod). Cannot itself be table. |
字段类型引用
字段类型 | 最适合 | 示例字段描述 |
|---|---|---|
string | Names, identifiers, codes, free text | Customer name as printed on the invoice header. |
number | Amounts, quantities, tax rates, counts | Grand total of the order in the document currency, including taxes. |
date | Dates, due dates, issue dates, timestamps | Date the invoice was issued, accept DD/MM/YYYY and 5 June 2026 formats. |
table | Repeated rows (line items, addresses, transactions) | All product / service rows from the invoice table. Carries a nested fields array describing the columns. |
步骤 5:保存更改并使用分析器
点击 保存更改 在左上角添加设置以保存模式。分析器现已激活,可通过其分析器 ID 从任何平台引用。
使用分析器 API 或自动化呼叫
保存后,同一个分析器可以通过引用在任何平台上运行。您无需在每个平台上重新创建架构。
| 场地 | 来源 | 目的 |
|---|---|---|
AnalyzerId | 你在步骤 2 中输入的字符串 | AI解析器用于定位您的模式的稳定标识符。 |
docName | 来源 PDF 文件名 | 用于跟踪和错误消息。 |
docContent | 来源 PDF 编码为 Base64 | 要从中提取信息的文档。 |
async | false 对于同步, true 用于民意调查 | 控制响应的传递。 |
例子 REST 请求正文:
{
"docName": "purchase_order.pdf",
"docContent": "BASE64_ENCODED_PDF_CONTENT",
"AnalyzerId": "purchase_order_parser",
"async": false
}
响应中包含您在“定义”中定义的每个项目的相应字段。 fields路线 JSON 进入任何下游系统: Google Sheets, Airtable一个数据库, Excel或者使用 webhook。
常用工作流程
典型的AI解析器模式How a saved Analyzer moves from dashboard to production.
- 一份新的采购订单 PDF 到达受监控的邮箱或上传文件夹。
- Make, Zapier, Power Automate, 或者 n8n 调用 AI 解析器
分析器 ID:purchase_order_parser。 - 返回 JSON (
销售订单号,代理名称,订单日期,总金额)映射到你的 ERP 创建订单 API。 - 系统会使用解析后的订单号向客户发送确认邮件。
- 发票 PDF 通过 webhook、监视文件夹或共享收件箱到达。
- AI解析器被调用时
分析器 ID:invoice_parser(发票快速填写方案)。 - 结构化响应(
发票编号,总金额,到期日)作为一行附加到 Google Sheets 或者 Excel 致会计团队。
- 一个受监控的文件夹接收混合文件(发票、采购订单、发货单)。
- 分类分析器会将每个文件路由到正确的类别标签。
- 根据标签,工作流程会调用匹配的解析分析器(
发票解析器,采购订单解析器,发货单解析器)并将结构化输出写入正确的目标位置。
模式最佳实践
- 使用描述性语言
fieldDescription字符串。提及您在实际文档中看到的别名(例如“销售订单号,也称为 SO 编号、订单参考号或 PO 参考号”)。 - 挑选
fieldType小心地。date和number给引擎提供解析提示;string当形状无法预测时,这是备用方案。 - 保持
fieldName机器可读(驼峰式或帕斯卡式,无空格)。它显示为 JSON 答案中的关键点。 - 先从发票或采购订单的快速填充功能开始,然后精简或添加字段。预设值是很好的基准。
- 在将生产流量投入分析器之前,先用三个真实样本进行测试,包括缺少可选字段、第二页文档和 OCR 衍生文本等极端情况。
- 版本分析器 ID(在进行重大架构更改时)
invoice_parser_v1,invoice_parser_v2因此,实时自动化可以按照自己的节奏迁移。