跳到正文

PDF

生成、合并、拆分、OCR 与加水印 PDF。

概览

基础路径: https://api.infrai.cc/v1/pdf
鉴权头: Authorization: Bearer $INFRAI_API_KEY
bash
# Call any /v1/pdf capability over raw HTTP — no SDK to install.
# curl:
curl https://api.infrai.cc/v1/pdf/... \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json"

方法

pdf.generate

POST /v1/pdf/generate

从 HTML、URL 或模板生成 PDF。

参数

名称类型必填说明
htmlstring可选要渲染的 HTML 源。
urlstring可选用于渲染或操作的源 URL。
template_idstring可选用于渲染的模板 id(替代正文)。
format"A4" | "Letter" | "Legal"可选页面尺寸。
orientation"portrait" | "landscape"可选页面方向。
idempotency_keystring可选可选去重 key;相同重试将返回同一结果。

返回

PdfResult { pdf_url, bytes, pages }

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X POST https://api.infrai.cc/v1/pdf/generate \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"html": "<h1>Invoice #42</h1>", "page_size": "A4", "orientation": "portrait"}'

pdf.merge

POST /v1/pdf/merge

将多个 PDF 合并为一个。

参数

名称类型必填说明
urlsstring[]
必填
要合并的 PDF URL 列表。

返回

PdfResult

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X POST https://api.infrai.cc/v1/pdf/merge \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"inputs": []}'

pdf.split

POST /v1/pdf/split

按页码区间拆分 PDF。

参数

名称类型必填说明
urlstring
必填
用于渲染或操作的源 URL。
rangesstring[]
必填
页码区间,例如 1-3。

返回

{ parts: PdfResult[] }

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X POST https://api.infrai.cc/v1/pdf/split \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"pdf": "...", "ranges": []}'

pdf.ocr

POST /v1/pdf/ocr

通过 OCR 从 PDF 提取文本。

参数

名称类型必填说明
urlstring
必填
用于渲染或操作的源 URL。
languagestring可选语言提示,例如 en 或 zh。

返回

{ text, pages: Array<{ text }> }

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X POST https://api.infrai.cc/v1/pdf/ocr \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/scan.pdf", "lang": "auto", "quality": "accurate"}'

pdf.watermark

POST /v1/pdf/watermark

为 PDF 添加文字或图片水印。

参数

名称类型必填说明
urlstring
必填
用于渲染或操作的源 URL。
textstring可选水印文字。
opacitynumber可选水印不透明度,0 到 1。

返回

PdfResult

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X POST https://api.infrai.cc/v1/pdf/watermark \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"pdf": "..."}'

pdf.compress

POST /v1/pdf/compress

压缩 PDF 以减小体积,mode 复用全局 fast/balanced/quality 处理档位;幂等写入,idempotency_key 用于重试去重。

参数

名称类型必填说明
pdfstring
必填
PDF 输入:URL、base64 数据或已存储的 pdf_id。
mode"fast" | "balanced" | "quality"可选压缩力度与保真的权衡,复用全局处理档位(fast/balanced/quality)。
idempotency_keystring可选可选去重 key;相同重试将返回同一结果。

返回

PdfDocument { pdf_id, url, bytes, page_count, source }

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X POST https://api.infrai.cc/v1/pdf/compress \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"pdf": "..."}'

pdf.convert

POST /v1/pdf/convert

将 PDF 转换为其他格式;不支持的目标返回 PDF_CONVERT_UNSUPPORTED(422);多页图片目标返回 PdfDocumentListResult;幂等写入。

参数

名称类型必填说明
pdfstring
必填
PDF 输入:URL、base64 数据或已存储的 pdf_id。
tostring
必填
目标格式(如 docx、png、jpg 等)。
idempotency_keystring可选可选去重 key;相同重试将返回同一结果。

返回

PdfDocument (multi-page image targets return PdfDocumentListResult)

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X POST https://api.infrai.cc/v1/pdf/convert \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"pdf": "...", "to": "docx"}'

pdf.parse

POST /v1/pdf/parse

提取 PDF 文本、大纲与元数据用于 RAG 入库;只读无副作用;加密且未提供密码时返回 PDF_PARSE_PASSWORD_REQUIRED。

参数

名称类型必填说明
pdfstring
必填
PDF 输入:URL、base64 数据或已存储的 pdf_id。
pagesnumber[]可选限定解析的页码(1 起始);省略则解析全部页面。

返回

PdfParseResult { text, pages, outline, metadata }

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X POST https://api.infrai.cc/v1/pdf/parse \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"pdf": "..."}'

pdf.extract_images

POST /v1/pdf/extract_images

提取 PDF 内嵌 XObject 图片并以 data: URI 形式返回;只读无副作用。

参数

名称类型必填说明
pdfstring
必填
PDF 输入:URL、base64 数据或已存储的 pdf_id。
pagesnumber[]可选限定提取图片的页码(1 起始);省略则提取全部页面。

返回

PdfExtractImagesResult { images: ExtractedImage[] }

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X POST https://api.infrai.cc/v1/pdf/extract_images \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"pdf": "..."}'

pdf.form.extract

POST /v1/pdf/form/extract

读取 AcroForm 表单字段名与取值;只读无副作用。

参数

名称类型必填说明
pdfstring
必填
PDF 输入:URL、base64 数据或已存储的 pdf_id。

返回

PdfFormExtractResult { fields }

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X POST https://api.infrai.cc/v1/pdf/form/extract \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"pdf": "..."}'

pdf.form.fill

POST /v1/pdf/form/fill

填充 AcroForm 表单字段;flatten 压平为不可编辑;幂等写入,idempotency_key 用于重试去重。

参数

名称类型必填说明
pdfstring
必填
PDF 输入:URL、base64 数据或已存储的 pdf_id。
fieldsRecord<string, string>
必填
字段名到取值的映射,用于填充表单。
flattenboolean可选为 true 时将填充值压平,使表单不可再编辑。
idempotency_keystring可选可选去重 key;相同重试将返回同一结果。

返回

PdfDocument { pdf_id, url, page_count, source }

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X POST https://api.infrai.cc/v1/pdf/form/fill \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"pdf": "...", "fields": {}}'

pdf.encrypt

POST /v1/pdf/encrypt

为 PDF 应用密码与权限加密;幂等写入,idempotency_key 用于重试去重。

参数

名称类型必填说明
pdfstring
必填
PDF 输入:URL、base64 数据或已存储的 pdf_id。
user_passwordstring可选打开文档所需的用户密码。
owner_passwordstring可选用于权限控制的所有者密码。
permissionsstring[]可选允许的操作权限列表(如 print、copy 等)。
idempotency_keystring可选可选去重 key;相同重试将返回同一结果。

返回

PdfDocument { pdf_id, url, source }

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X POST https://api.infrai.cc/v1/pdf/encrypt \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"pdf": "..."}'

pdf.decrypt

POST /v1/pdf/decrypt

去除 PDF 密码保护;缺密码返回 PDF_PARSE_PASSWORD_REQUIRED(401),密码错误返回 PDF_DECRYPT_FAILED(403);幂等写入。

参数

名称类型必填说明
pdfstring
必填
PDF 输入:URL、base64 数据或已存储的 pdf_id。
passwordstring
必填
用于解密文档的密码。
idempotency_keystring可选可选去重 key;相同重试将返回同一结果。

返回

PdfDocument { pdf_id, url, source }

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X POST https://api.infrai.cc/v1/pdf/decrypt \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"pdf": "...", "password": "..."}'

pdf.rotate

POST /v1/pdf/rotate

旋转指定页面;角度不在 {0,90,180,270} 或页码越界均返回 PDF_TEMPLATE_INVALID;幂等写入。

参数

名称类型必填说明
pdfstring
必填
PDF 输入:URL、base64 数据或已存储的 pdf_id。
degrees0 | 90 | 180 | 270可选旋转角度,取值 0、90、180 或 270。
pagesnumber[]可选限定旋转的页码(1 起始);省略则旋转全部页面。
idempotency_keystring可选可选去重 key;相同重试将返回同一结果。

返回

PdfDocument { pdf_id, url, source }

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X POST https://api.infrai.cc/v1/pdf/rotate \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"pdf": "..."}'

pdf.redact

POST /v1/pdf/redact

按区域或正则模式不可逆地涂黑内容;幂等写入,idempotency_key 用于重试去重。

参数

名称类型必填说明
pdfstring
必填
PDF 输入:URL、base64 数据或已存储的 pdf_id。
regionsArray<{ page; x; y; width; height }>可选需涂黑的矩形区域列表(含页码与坐标尺寸)。
patternsstring[]可选用于匹配并涂黑敏感内容的正则模式列表。
idempotency_keystring可选可选去重 key;相同重试将返回同一结果。

返回

PdfDocument { pdf_id, url, source }

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X POST https://api.infrai.cc/v1/pdf/redact \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"pdf": "..."}'

pdf.sign

POST /v1/pdf/sign

为 PDF 应用 PKCS#7 / PAdES 数字签名;证书/私钥 PEM 头无效返回 PDF_SIGN_CERT_INVALID;幂等写入。

参数

名称类型必填说明
pdfstring
必填
PDF 输入:URL、base64 数据或已存储的 pdf_id。
cert_pemstring
必填
签名证书的 PEM 文本(须含有效 PEM 头)。
key_pemstring
必填
签名私钥的 PEM 文本(须含有效 PEM 头)。
reasonstring可选签名原因(可选,写入签名元数据)。
locationstring可选签名地点(可选,写入签名元数据)。
retention_daysnumber可选签名产物的保留天数(可选)。
idempotency_keystring可选可选去重 key;相同重试将返回同一结果。

返回

SignedPdfDocument { pdf_id, url, signed_at, signer }

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X POST https://api.infrai.cc/v1/pdf/sign \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"pdf": "...", "cert_pem": "...", "key_pem": "..."}'

pdf.verify

POST /v1/pdf/verify

根据证书校验已签名 PDF 的签名有效性;只读无副作用;cert_pem 必填。

参数

名称类型必填说明
signed_pdfstring
必填
已签名的 PDF 输入:URL、base64 数据或已存储的 pdf_id。
cert_pemstring
必填
用于校验签名的证书 PEM 文本。

返回

SignatureVerification { valid, signer, signed_at }

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X POST https://api.infrai.cc/v1/pdf/verify \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"signed_pdf": "...", "cert_pem": "..."}'

pdf.get

GET /v1/pdf/get/{pdf_id}

按 pdf_id 获取单个 PDF 文档详情。

参数

名称类型必填说明
pdf_idstring
必填
PDF 文档标识符(形如 pdf_…)。

返回

PdfDocument { pdf_id, url, bytes, page_count, source, created_at }

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X GET https://api.infrai.cc/v1/pdf/get/PDF_ID \
  -H "Authorization: Bearer $INFRAI_API_KEY"

pdf.list

GET /v1/pdf/list

分页列出账户下的 PDF 文档;cursor 取自上一页,limit 默认 50(1-200)。

参数

名称类型必填说明
cursorstring可选上一页返回的不透明游标;null 表示第一页。
limitnumber可选单页返回数量,默认 50,范围 1-200。

返回

PdfDocumentListResult { items: PdfDocument[], next_cursor }

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X GET https://api.infrai.cc/v1/pdf/list \
  -H "Authorization: Bearer $INFRAI_API_KEY"

pdf.delete

DELETE /v1/pdf/delete/{pdf_id}

按 pdf_id 删除 PDF 文档;未知 id 返回 404 PDF_NOT_FOUND;幂等写入。

参数

名称类型必填说明
pdf_idstring
必填
要删除的 PDF 文档标识符(形如 pdf_…)。
idempotency_keystring可选可选去重 key;相同重试将返回同一结果。

返回

{ deleted: boolean, pdf_id }

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X DELETE https://api.infrai.cc/v1/pdf/delete/PDF_ID \
  -H "Authorization: Bearer $INFRAI_API_KEY"

pdf.job.get

GET /v1/pdf/job/get/{job_id}

按 job_id 查询异步 PDF 作业的状态与结果。

参数

名称类型必填说明
job_idstring
必填
异步 PDF 作业标识符。

返回

PdfJob { job_id, status, result, error }

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X GET https://api.infrai.cc/v1/pdf/job/get/JOB_ID \
  -H "Authorization: Bearer $INFRAI_API_KEY"

pdf.template.create

POST /v1/pdf/template/create

创建可复用的 HTML PDF 模板;幂等写入,idempotency_key 用于重试去重。

参数

名称类型必填说明
namestring
必填
模板名称。
htmlstring
必填
模板的 HTML 内容,可含变量占位符。
vars_schemaobject可选模板变量的 JSON Schema(可选),用于校验渲染入参。
idempotency_keystring可选可选去重 key;相同重试将返回同一结果。

返回

PdfTemplate { template_id, name, created_at }

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X POST https://api.infrai.cc/v1/pdf/template/create \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "...", "html": "..."}'

pdf.template.get

GET /v1/pdf/template/get/{template_id}

按 template_id 获取 PDF 模板详情。

参数

名称类型必填说明
template_idstring
必填
PDF 模板标识符(形如 tpl_…)。

返回

PdfTemplate { template_id, name, html, vars_schema }

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X GET https://api.infrai.cc/v1/pdf/template/get/TEMPLATE_ID \
  -H "Authorization: Bearer $INFRAI_API_KEY"

pdf.template.list

GET /v1/pdf/template/list

分页列出 PDF 模板;cursor 取自上一页,limit 默认 50(1-200)。

参数

名称类型必填说明
cursorstring可选上一页返回的不透明游标;null 表示第一页。
limitnumber可选单页返回数量,默认 50,范围 1-200。

返回

PdfTemplateListResult { items: PdfTemplate[], next_cursor }

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X GET https://api.infrai.cc/v1/pdf/template/list \
  -H "Authorization: Bearer $INFRAI_API_KEY"

pdf.template.delete

DELETE /v1/pdf/template/delete/{template_id}

按 template_id 删除 PDF 模板;未知 id 返回 404 PDF_TEMPLATE_NOT_FOUND;幂等写入。

参数

名称类型必填说明
template_idstring
必填
要删除的 PDF 模板标识符(形如 tpl_…)。
idempotency_keystring可选可选去重 key;相同重试将返回同一结果。

返回

{ deleted: boolean, template_id }

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X DELETE https://api.infrai.cc/v1/pdf/template/delete/TEMPLATE_ID \
  -H "Authorization: Bearer $INFRAI_API_KEY"

pdf.retention.get

GET /v1/pdf/retention/get

查询当前 PDF 产物的保留期策略。

返回

PdfRetentionPolicy { days, hard_max }

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X GET https://api.infrai.cc/v1/pdf/retention/get \
  -H "Authorization: Bearer $INFRAI_API_KEY"

pdf.retention.set

PUT /v1/pdf/retention/set

设置 PDF 产物保留窗口(PUT,幂等);超过 30 天(上限 90 天)需 confirmation=true,否则返回 PDF_TEMPLATE_INVALID(400)。

参数

名称类型必填说明
daysnumber
必填
产物保留天数(1-90)。
confirmationboolean可选设置超过 30 天的较长窗口时必须为 true(成本/合规确认)。
idempotency_keystring可选可选去重 key;相同重试将返回同一结果。

返回

PdfRetentionPolicy { days, hard_max }

示例

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
curl -X PUT https://api.infrai.cc/v1/pdf/retention/set \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"days": 0}'

全部能力

本模块全部已路由能力——完整的对外 REST 契约。上方方法是带讲解的入门示例,此表是完整参考。

能力端点说明
pdf.compressPOST /v1/pdf/compressCompress a PDF to reduce file size, using the global fast/balanced/quality processing mode; idempotent write.
pdf.convertPOST /v1/pdf/convertConvert a PDF to another format; unsupported targets return PDF_CONVERT_UNSUPPORTED (422); idempotent write.
pdf.decryptPOST /v1/pdf/decryptRemove password protection from a PDF; wrong password returns PDF_DECRYPT_FAILED (403); idempotent write.
pdf.deleteDELETE /v1/pdf/delete/{pdf_id}Delete a PDF document by pdf_id; unknown id returns 404 PDF_NOT_FOUND; idempotent write.
pdf.encryptPOST /v1/pdf/encryptEncrypt a PDF with a password and permission flags; idempotent write.
pdf.extract_imagesPOST /v1/pdf/extract_imagesExtract embedded images from a PDF, returned as data: URIs; read-only, no side effects.
pdf.form.extractPOST /v1/pdf/form/extractRead AcroForm field names and values from a PDF; read-only, no side effects.
pdf.form.fillPOST /v1/pdf/form/fillFill AcroForm fields, optionally flattening to a non-editable PDF; idempotent write.
pdf.generatePOST /v1/pdf/generateGenerate a PDF from HTML, Markdown, inline template, or a stored template rendered with variables; idempotent write.
pdf.getGET /v1/pdf/get/{pdf_id}Retrieve a single PDF document's details by pdf_id.
pdf.job.getGET /v1/pdf/job/get/{job_id}Get the status and result of an asynchronous PDF job by job_id.
pdf.listGET /v1/pdf/listList the account's PDF documents with cursor-based pagination.
pdf.mergePOST /v1/pdf/mergeConcatenate multiple PDFs in order into a single document; idempotent write.
pdf.ocrPOST /v1/pdf/ocrRun OCR on a scanned PDF; unsupported language returns PDF_OCR_LANG_UNSUPPORTED (400); idempotent write.
pdf.parsePOST /v1/pdf/parseExtract text, outline, and metadata from a PDF for RAG ingestion; read-only, no side effects.
pdf.redactPOST /v1/pdf/redactIrreversibly black out content by region or regex pattern; idempotent write.
pdf.retention.getGET /v1/pdf/retention/getGet the retention policy for generated PDF artifacts.
pdf.retention.setPUT /v1/pdf/retention/setSet the PDF artifact retention window; beyond 30 days (max 90) requires confirmation=true; idempotent write (PUT).
pdf.rotatePOST /v1/pdf/rotateRotate specified pages by 0, 90, 180, or 270 degrees; idempotent write.
pdf.signPOST /v1/pdf/signApply a PKCS#7 / PAdES digital signature to a PDF; invalid certificate returns PDF_SIGN_CERT_INVALID (not channel-auth signing — see realtime.auth.sign); idempotent write.
pdf.splitPOST /v1/pdf/splitSplit a PDF into multiple documents by 1-indexed inclusive page ranges; idempotent write.
pdf.template.createPOST /v1/pdf/template/createCreate a reusable HTML PDF template; idempotent write.
pdf.template.deleteDELETE /v1/pdf/template/delete/{template_id}Delete a PDF template by template_id; unknown id returns 404 PDF_TEMPLATE_NOT_FOUND; idempotent write.
pdf.template.getGET /v1/pdf/template/get/{template_id}Retrieve a PDF template's details by template_id.
pdf.template.listGET /v1/pdf/template/listList PDF templates with cursor-based pagination.
pdf.verifyPOST /v1/pdf/verifyVerify a signed PDF's signature validity against a certificate; read-only, no side effects.
pdf.watermarkPOST /v1/pdf/watermarkStamp a text and/or image watermark onto a PDF; idempotent write.

完整示例

本模块的生产级端到端范例:先一次性配置,再运行业务流程,尽量覆盖本模块的多数 API。

一次性前置(每个范例都假定已完成):

bash
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at the console: Google/GitHub gives you
# $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
# POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."
bash
# 1) Auth: every call is a raw HTTPS request to the Infrai gateway carrying
#    only your project key. No SDK, no install.
#    Get your key: sign in with Google/GitHub at the console for a project key
#    + $2 free credit (email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT,
#    POST /v1/account/topup and open the returned checkout_url.
export INFRAI_API_KEY="ifr_pk_proj_..."   # from the console


# 2) pdf.generate
curl -X POST https://api.infrai.cc/v1/pdf/generate \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"html": "<h1>Invoice #42</h1>", "page_size": "A4", "orientation": "portrait"}'

# 3) pdf.merge
curl -X POST https://api.infrai.cc/v1/pdf/merge \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"inputs": []}'

# 4) pdf.split
curl -X POST https://api.infrai.cc/v1/pdf/split \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"pdf": "...", "ranges": []}'

# 5) pdf.ocr
curl -X POST https://api.infrai.cc/v1/pdf/ocr \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/scan.pdf", "lang": "auto", "quality": "accurate"}'

# 6) pdf.watermark
curl -X POST https://api.infrai.cc/v1/pdf/watermark \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"pdf": "..."}'

# 7) pdf.compress
curl -X POST https://api.infrai.cc/v1/pdf/compress \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"pdf": "..."}'

# 8) pdf.convert
curl -X POST https://api.infrai.cc/v1/pdf/convert \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"pdf": "...", "to": "docx"}'

# 9) pdf.parse
curl -X POST https://api.infrai.cc/v1/pdf/parse \
  -H "Authorization: Bearer $INFRAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"pdf": "..."}'