填写 PDF 形式
PDF4me 填写PDF表格 在 AcroForm 中填充字段 PDF 包含来自以下对象的值的模板 JSON 单个对象 REST 致电。发送模板。 Base64 或公众 URL将字段值作为字符串发送。 数据数组并接收已填好的 PDF 以二进制字节 (200) 或通过 Location 标头轮询 URL (202)切换 KeepPdf可编辑 提供可重新编辑的表单或扁平化的静态记录。
验证您的身份 API 要求
每一个 PDF4me REST 通话必须包含您的 API 关键在于 Authorization 请求头设置为基本身份验证。请从开发者控制面板获取或轮换您的密钥。
端点
/api/v2/FillPdfFormhttps://api.pdf4me.com/api/v2/FillPdfForm您不容错过的重要事实
数据数组 是一个字符串,而不是一个对象。JSON.stringify({...}) 发布前请注意,发送嵌套对象会返回反序列化错误。IsAsync: true 这 API 可能会响应 202 和 Location 标头。 GET 那 URL (相同的授权)直到它返回 200 为止 PDF 二进制。标准 PDF4me 异步模式(pdf4meAsyncRequest)。HTTP 设置
方法: 邮政
URL: https://api.pdf4me.com/api/v2/FillPdfForm
内容类型: application/json
授权: 基本 <您的 PDF4me API 键>
发送 IsAsync: true 在体内。 200 返回已填充的内容 PDF 以二进制字节形式表示。 202 返回一个 地点 带有投票的标题 URL; GET 那 URL 使用相同的 Authorization 标头,直到返回 200 状态码为止。 PDF 二进制(与二进制相同) pdf4meAsyncRequest)。
变异矩阵(与 Postman 相关)
三种输入方式涵盖了所有 Postman / curl / SDK 调用。请选择与您的需求相匹配的输入方式。 PDF 模板和表单数据实时更新。
| 变体 | PDF模板(模板文档内容) | 表单字段 | 必填 API 字段 |
|---|---|---|---|
| A | Base64 PDF | JSON object → stringify → dataArray | All rows in the JSON-form table below. |
| B | Public PDF URL | JSON object → stringify → dataArray | Same as A; templateDocContent is the URL string. |
| C | Base64 PDF | Base64-encoded JSON file → decode → stringify into dataArray | Same as A; build dataArray from the decoded JSON. |
API 身体场
总是发送
| 场地 | 必需的 | 类型 | 默认/备注 |
|---|---|---|---|
templateDocName | Yes* | string | Filename of the template, e.g. template.pdf. Derived from the source URL filename or defaulted to template.pdf. Used for downstream output naming. |
templateDocContent | Yes | string | Base64-encoded PDF (no data: prefix) OR a publicly reachable https URL to the PDF. |
KeepPdfEditable | No | boolean | Default false. Set true to keep AcroForm fields editable in the output PDF; false flattens the form into static text. |
IsAsync | Yes | boolean | Default true. Toggles the 200 / 202 + Location async pattern. |
*模板文档名称 必须始终在请求中设置;选择一个合理的文件名,以便下游输出文件名清晰明了。
当表单输入是 JSON
| 场地 | 必需的 | 类型 | 笔记 |
|---|---|---|---|
dataArray | Yes | string | JSON.stringify({ ... }). Keys = AcroForm field names; values = strings to fill. |
inputDataType | Yes | string | Always "json" for this path. |
outputType | Yes | string | Always "pdf". |
表单数据规则(JSON 小路)
| 规则 | 细节 |
|---|---|
| Shape | Single object: {"fieldName": "value", ...}. |
| Not allowed | Empty array, or an array of multiple objects. |
| Base64 form input | Decode the UTF-8 JSON file, then JSON.stringify into dataArray. In Postman: put the decoded-then-stringified result directly into dataArray. |
| Data URL | Strip the data:...;base64, prefix if present (applies to the PDF Base64 in templateDocContent). |
示例有效载荷
版本 A. PDF Base64 + 表单 JSON
{
"templateDocName": "application-form.pdf",
"templateDocContent": "JVBERi0xLjQKJcfsj6IKNSAwIG9iago8PAovVHlwZSAvQ2F0YWxvZw...",
"inputDataType": "json",
"outputType": "pdf",
"KeepPdfEditable": false,
"IsAsync": true
}
数据数组 必须是字符串,不能是嵌套字符串。 JSON 目的:
"dataArray": "{"firstname":"John","lastname":"Doe"}"
方案 B. PDF URL + 表单 JSON
{
"templateDocName": "application-form.pdf",
"templateDocContent": "https://example.com/forms/application-form.pdf",
"inputDataType": "json",
"outputType": "pdf",
"KeepPdfEditable": false,
"IsAsync": true
}
变体 C. PDF Base64 + 来自 base64 JSON 的表单
仓库中的占位符: eyJmaXJzdG5hbWUiOiJKb2huIn0= → {"firstname":"John"}。
相等的 API 身体 解码表单后 JSON:
{
"templateDocName": "application-form.pdf",
"templateDocContent": "JVBERi0xLjQKJcfsj6IKNSAwIG9iago8PAovVHlwZSAvQ2F0YWxvZw...",
"dataArray": "{\"firstname\": \"John\"}",
"inputDataType": "json",
"outputType": "pdf",
"KeepPdfEditable": false,
"IsAsync": true
}
可选。保持表单可编辑
{
"templateDocName": "application-form.pdf",
"templateDocContent": "https://example.com/forms/application-form.pdf",
"dataArray": "{\"firstname\": \"John\", \"lastname\": \"Doe\"}",
"inputDataType": "json",
"outputType": "pdf",
"KeepPdfEditable": true,
"IsAsync": true
}
邮递员收款小贴士
curl 示例
curl -X POST https://api.pdf4me.com/api/v2/FillPdfForm \
-H "Content-Type: application/json" \
-H "Authorization: Basic YOUR_API_KEY" \
-d '{
"templateDocName": "application-form.pdf",
"templateDocContent": "https://example.com/forms/application-form.pdf",
"dataArray": "{\"firstname\":\"John\",\"lastname\":\"Doe\"}",
"inputDataType": "json",
"outputType": "pdf",
"KeepPdfEditable": false,
"IsAsync": true
}' \
--output filled-form.pdf
快速参考:必填项与可选项(Postman)
| 场地 | A (PDF b64) | B(PDF URL) | C(b64 格式 → JSON) |
|---|---|---|---|
templateDocName | Required | Required | Required |
templateDocContent | Required (b64) | Required (URL) | Required (b64) |
dataArray | Required | Required | Required (from decoded JSON) |
inputDataType | Required (json) | Required (json) | Required (json) |
outputType | Required (pdf) | Required (pdf) | Required (pdf) |
IsAsync | Required (true) | Required (true) | Required (true) |
KeepPdfEditable | Optional | Optional | Optional |