Generate, merge, split, OCR and watermark PDFs.
Overview
https://api.infrai.cc/v1/pdfAuthorization: Bearer $INFRAI_API_KEY# 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"Methods
pdf.generate
Generate a PDF from HTML, a URL or a template.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
html | string | Optional | HTML source to render. |
url | string | Optional | Source URL to render or operate on. |
template_id | string | Optional | Template id to render instead of a body. |
format | "A4" | "Letter" | "Legal" | Optional | Page size. |
orientation | "portrait" | "landscape" | Optional | Page orientation. |
idempotency_key | string | Optional | Optional dedup key; identical retries return the same result. |
Returns
PdfResult { pdf_url, bytes, pages }Example
一次性前置(每个范例都假定已完成):
# 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_..."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
Merge several PDFs into one.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
urls | string[] | Required | List of PDF URLs to merge. |
Returns
PdfResultExample
一次性前置(每个范例都假定已完成):
# 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_..."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
Split a PDF by page ranges.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
url | string | Required | Source URL to render or operate on. |
ranges | string[] | Required | Page ranges, e.g. 1-3. |
Returns
{ parts: PdfResult[] }Example
一次性前置(每个范例都假定已完成):
# 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_..."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
Extract text from a PDF via OCR.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
url | string | Required | Source URL to render or operate on. |
language | string | Optional | Language hint, e.g. en or zh. |
Returns
{ text, pages: Array<{ text }> }Example
一次性前置(每个范例都假定已完成):
# 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_..."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
Apply a text or image watermark to a PDF.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
url | string | Required | Source URL to render or operate on. |
text | string | Optional | Watermark text. |
opacity | number | Optional | Watermark opacity from 0 to 1. |
Returns
PdfResultExample
一次性前置(每个范例都假定已完成):
# 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_..."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
压缩 PDF 以减小体积,mode 复用全局 fast/balanced/quality 处理档位;幂等写入,idempotency_key 用于重试去重。
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
pdf | string | Required | PDF 输入:URL、base64 数据或已存储的 pdf_id。 |
mode | "fast" | "balanced" | "quality" | Optional | 压缩力度与保真的权衡,复用全局处理档位(fast/balanced/quality)。 |
idempotency_key | string | Optional | Optional dedup key; identical retries return the same result. |
Returns
PdfDocument { pdf_id, url, bytes, page_count, source }Example
一次性前置(每个范例都假定已完成):
# 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_..."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
将 PDF 转换为其他格式;不支持的目标返回 PDF_CONVERT_UNSUPPORTED(422);多页图片目标返回 PdfDocumentListResult;幂等写入。
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
pdf | string | Required | PDF 输入:URL、base64 数据或已存储的 pdf_id。 |
to | string | Required | 目标格式(如 docx、png、jpg 等)。 |
idempotency_key | string | Optional | Optional dedup key; identical retries return the same result. |
Returns
PdfDocument (multi-page image targets return PdfDocumentListResult)Example
一次性前置(每个范例都假定已完成):
# 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_..."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
提取 PDF 文本、大纲与元数据用于 RAG 入库;只读无副作用;加密且未提供密码时返回 PDF_PARSE_PASSWORD_REQUIRED。
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
pdf | string | Required | PDF 输入:URL、base64 数据或已存储的 pdf_id。 |
pages | number[] | Optional | 限定解析的页码(1 起始);省略则解析全部页面。 |
Returns
PdfParseResult { text, pages, outline, metadata }Example
一次性前置(每个范例都假定已完成):
# 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_..."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
提取 PDF 内嵌 XObject 图片并以 data: URI 形式返回;只读无副作用。
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
pdf | string | Required | PDF 输入:URL、base64 数据或已存储的 pdf_id。 |
pages | number[] | Optional | 限定提取图片的页码(1 起始);省略则提取全部页面。 |
Returns
PdfExtractImagesResult { images: ExtractedImage[] }Example
一次性前置(每个范例都假定已完成):
# 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_..."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
读取 AcroForm 表单字段名与取值;只读无副作用。
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
pdf | string | Required | PDF 输入:URL、base64 数据或已存储的 pdf_id。 |
Returns
PdfFormExtractResult { fields }Example
一次性前置(每个范例都假定已完成):
# 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_..."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
填充 AcroForm 表单字段;flatten 压平为不可编辑;幂等写入,idempotency_key 用于重试去重。
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
pdf | string | Required | PDF 输入:URL、base64 数据或已存储的 pdf_id。 |
fields | Record<string, string> | Required | 字段名到取值的映射,用于填充表单。 |
flatten | boolean | Optional | 为 true 时将填充值压平,使表单不可再编辑。 |
idempotency_key | string | Optional | Optional dedup key; identical retries return the same result. |
Returns
PdfDocument { pdf_id, url, page_count, source }Example
一次性前置(每个范例都假定已完成):
# 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_..."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
为 PDF 应用密码与权限加密;幂等写入,idempotency_key 用于重试去重。
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
pdf | string | Required | PDF 输入:URL、base64 数据或已存储的 pdf_id。 |
user_password | string | Optional | 打开文档所需的用户密码。 |
owner_password | string | Optional | 用于权限控制的所有者密码。 |
permissions | string[] | Optional | 允许的操作权限列表(如 print、copy 等)。 |
idempotency_key | string | Optional | Optional dedup key; identical retries return the same result. |
Returns
PdfDocument { pdf_id, url, source }Example
一次性前置(每个范例都假定已完成):
# 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_..."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
去除 PDF 密码保护;缺密码返回 PDF_PARSE_PASSWORD_REQUIRED(401),密码错误返回 PDF_DECRYPT_FAILED(403);幂等写入。
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
pdf | string | Required | PDF 输入:URL、base64 数据或已存储的 pdf_id。 |
password | string | Required | 用于解密文档的密码。 |
idempotency_key | string | Optional | Optional dedup key; identical retries return the same result. |
Returns
PdfDocument { pdf_id, url, source }Example
一次性前置(每个范例都假定已完成):
# 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_..."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
旋转指定页面;角度不在 {0,90,180,270} 或页码越界均返回 PDF_TEMPLATE_INVALID;幂等写入。
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
pdf | string | Required | PDF 输入:URL、base64 数据或已存储的 pdf_id。 |
degrees | 0 | 90 | 180 | 270 | Optional | 旋转角度,取值 0、90、180 或 270。 |
pages | number[] | Optional | 限定旋转的页码(1 起始);省略则旋转全部页面。 |
idempotency_key | string | Optional | Optional dedup key; identical retries return the same result. |
Returns
PdfDocument { pdf_id, url, source }Example
一次性前置(每个范例都假定已完成):
# 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_..."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
按区域或正则模式不可逆地涂黑内容;幂等写入,idempotency_key 用于重试去重。
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
pdf | string | Required | PDF 输入:URL、base64 数据或已存储的 pdf_id。 |
regions | Array<{ page; x; y; width; height }> | Optional | 需涂黑的矩形区域列表(含页码与坐标尺寸)。 |
patterns | string[] | Optional | 用于匹配并涂黑敏感内容的正则模式列表。 |
idempotency_key | string | Optional | Optional dedup key; identical retries return the same result. |
Returns
PdfDocument { pdf_id, url, source }Example
一次性前置(每个范例都假定已完成):
# 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_..."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
为 PDF 应用 PKCS#7 / PAdES 数字签名;证书/私钥 PEM 头无效返回 PDF_SIGN_CERT_INVALID;幂等写入。
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
pdf | string | Required | PDF 输入:URL、base64 数据或已存储的 pdf_id。 |
cert_pem | string | Required | 签名证书的 PEM 文本(须含有效 PEM 头)。 |
key_pem | string | Required | 签名私钥的 PEM 文本(须含有效 PEM 头)。 |
reason | string | Optional | 签名原因(可选,写入签名元数据)。 |
location | string | Optional | 签名地点(可选,写入签名元数据)。 |
retention_days | number | Optional | 签名产物的保留天数(可选)。 |
idempotency_key | string | Optional | Optional dedup key; identical retries return the same result. |
Returns
SignedPdfDocument { pdf_id, url, signed_at, signer }Example
一次性前置(每个范例都假定已完成):
# 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_..."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
根据证书校验已签名 PDF 的签名有效性;只读无副作用;cert_pem 必填。
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
signed_pdf | string | Required | 已签名的 PDF 输入:URL、base64 数据或已存储的 pdf_id。 |
cert_pem | string | Required | 用于校验签名的证书 PEM 文本。 |
Returns
SignatureVerification { valid, signer, signed_at }Example
一次性前置(每个范例都假定已完成):
# 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_..."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
按 pdf_id 获取单个 PDF 文档详情。
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
pdf_id | string | Required | PDF 文档标识符(形如 pdf_…)。 |
Returns
PdfDocument { pdf_id, url, bytes, page_count, source, created_at }Example
一次性前置(每个范例都假定已完成):
# 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_..."curl -X GET https://api.infrai.cc/v1/pdf/get/PDF_ID \
-H "Authorization: Bearer $INFRAI_API_KEY"pdf.list
分页列出账户下的 PDF 文档;cursor 取自上一页,limit 默认 50(1-200)。
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
cursor | string | Optional | 上一页返回的不透明游标;null 表示第一页。 |
limit | number | Optional | 单页返回数量,默认 50,范围 1-200。 |
Returns
PdfDocumentListResult { items: PdfDocument[], next_cursor }Example
一次性前置(每个范例都假定已完成):
# 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_..."curl -X GET https://api.infrai.cc/v1/pdf/list \
-H "Authorization: Bearer $INFRAI_API_KEY"pdf.delete
按 pdf_id 删除 PDF 文档;未知 id 返回 404 PDF_NOT_FOUND;幂等写入。
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
pdf_id | string | Required | 要删除的 PDF 文档标识符(形如 pdf_…)。 |
idempotency_key | string | Optional | Optional dedup key; identical retries return the same result. |
Returns
{ deleted: boolean, pdf_id }Example
一次性前置(每个范例都假定已完成):
# 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_..."curl -X DELETE https://api.infrai.cc/v1/pdf/delete/PDF_ID \
-H "Authorization: Bearer $INFRAI_API_KEY"pdf.job.get
按 job_id 查询异步 PDF 作业的状态与结果。
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
job_id | string | Required | 异步 PDF 作业标识符。 |
Returns
PdfJob { job_id, status, result, error }Example
一次性前置(每个范例都假定已完成):
# 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_..."curl -X GET https://api.infrai.cc/v1/pdf/job/get/JOB_ID \
-H "Authorization: Bearer $INFRAI_API_KEY"pdf.template.create
创建可复用的 HTML PDF 模板;幂等写入,idempotency_key 用于重试去重。
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
name | string | Required | 模板名称。 |
html | string | Required | 模板的 HTML 内容,可含变量占位符。 |
vars_schema | object | Optional | 模板变量的 JSON Schema(可选),用于校验渲染入参。 |
idempotency_key | string | Optional | Optional dedup key; identical retries return the same result. |
Returns
PdfTemplate { template_id, name, created_at }Example
一次性前置(每个范例都假定已完成):
# 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_..."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
按 template_id 获取 PDF 模板详情。
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
template_id | string | Required | PDF 模板标识符(形如 tpl_…)。 |
Returns
PdfTemplate { template_id, name, html, vars_schema }Example
一次性前置(每个范例都假定已完成):
# 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_..."curl -X GET https://api.infrai.cc/v1/pdf/template/get/TEMPLATE_ID \
-H "Authorization: Bearer $INFRAI_API_KEY"pdf.template.list
分页列出 PDF 模板;cursor 取自上一页,limit 默认 50(1-200)。
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
cursor | string | Optional | 上一页返回的不透明游标;null 表示第一页。 |
limit | number | Optional | 单页返回数量,默认 50,范围 1-200。 |
Returns
PdfTemplateListResult { items: PdfTemplate[], next_cursor }Example
一次性前置(每个范例都假定已完成):
# 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_..."curl -X GET https://api.infrai.cc/v1/pdf/template/list \
-H "Authorization: Bearer $INFRAI_API_KEY"pdf.template.delete
按 template_id 删除 PDF 模板;未知 id 返回 404 PDF_TEMPLATE_NOT_FOUND;幂等写入。
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
template_id | string | Required | 要删除的 PDF 模板标识符(形如 tpl_…)。 |
idempotency_key | string | Optional | Optional dedup key; identical retries return the same result. |
Returns
{ deleted: boolean, template_id }Example
一次性前置(每个范例都假定已完成):
# 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_..."curl -X DELETE https://api.infrai.cc/v1/pdf/template/delete/TEMPLATE_ID \
-H "Authorization: Bearer $INFRAI_API_KEY"pdf.retention.get
查询当前 PDF 产物的保留期策略。
Returns
PdfRetentionPolicy { days, hard_max }Example
一次性前置(每个范例都假定已完成):
# 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_..."curl -X GET https://api.infrai.cc/v1/pdf/retention/get \
-H "Authorization: Bearer $INFRAI_API_KEY"pdf.retention.set
设置 PDF 产物保留窗口(PUT,幂等);超过 30 天(上限 90 天)需 confirmation=true,否则返回 PDF_TEMPLATE_INVALID(400)。
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
days | number | Required | 产物保留天数(1-90)。 |
confirmation | boolean | Optional | 设置超过 30 天的较长窗口时必须为 true(成本/合规确认)。 |
idempotency_key | string | Optional | Optional dedup key; identical retries return the same result. |
Returns
PdfRetentionPolicy { days, hard_max }Example
一次性前置(每个范例都假定已完成):
# 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_..."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}'All capabilities
Every routed capability in this module — the complete public REST contract. The methods above are the guided walkthrough; this index is the full reference.
| Capability | Endpoint | Description |
|---|---|---|
pdf.compress | POST /v1/pdf/compress | Compress a PDF to reduce file size, using the global fast/balanced/quality processing mode; idempotent write. |
pdf.convert | POST /v1/pdf/convert | Convert a PDF to another format; unsupported targets return PDF_CONVERT_UNSUPPORTED (422); idempotent write. |
pdf.decrypt | POST /v1/pdf/decrypt | Remove password protection from a PDF; wrong password returns PDF_DECRYPT_FAILED (403); idempotent write. |
pdf.delete | DELETE /v1/pdf/delete/{pdf_id} | Delete a PDF document by pdf_id; unknown id returns 404 PDF_NOT_FOUND; idempotent write. |
pdf.encrypt | POST /v1/pdf/encrypt | Encrypt a PDF with a password and permission flags; idempotent write. |
pdf.extract_images | POST /v1/pdf/extract_images | Extract embedded images from a PDF, returned as data: URIs; read-only, no side effects. |
pdf.form.extract | POST /v1/pdf/form/extract | Read AcroForm field names and values from a PDF; read-only, no side effects. |
pdf.form.fill | POST /v1/pdf/form/fill | Fill AcroForm fields, optionally flattening to a non-editable PDF; idempotent write. |
pdf.generate | POST /v1/pdf/generate | Generate a PDF from HTML, Markdown, inline template, or a stored template rendered with variables; idempotent write. |
pdf.get | GET /v1/pdf/get/{pdf_id} | Retrieve a single PDF document's details by pdf_id. |
pdf.job.get | GET /v1/pdf/job/get/{job_id} | Get the status and result of an asynchronous PDF job by job_id. |
pdf.list | GET /v1/pdf/list | List the account's PDF documents with cursor-based pagination. |
pdf.merge | POST /v1/pdf/merge | Concatenate multiple PDFs in order into a single document; idempotent write. |
pdf.ocr | POST /v1/pdf/ocr | Run OCR on a scanned PDF; unsupported language returns PDF_OCR_LANG_UNSUPPORTED (400); idempotent write. |
pdf.parse | POST /v1/pdf/parse | Extract text, outline, and metadata from a PDF for RAG ingestion; read-only, no side effects. |
pdf.redact | POST /v1/pdf/redact | Irreversibly black out content by region or regex pattern; idempotent write. |
pdf.retention.get | GET /v1/pdf/retention/get | Get the retention policy for generated PDF artifacts. |
pdf.retention.set | PUT /v1/pdf/retention/set | Set the PDF artifact retention window; beyond 30 days (max 90) requires confirmation=true; idempotent write (PUT). |
pdf.rotate | POST /v1/pdf/rotate | Rotate specified pages by 0, 90, 180, or 270 degrees; idempotent write. |
pdf.sign | POST /v1/pdf/sign | Apply 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.split | POST /v1/pdf/split | Split a PDF into multiple documents by 1-indexed inclusive page ranges; idempotent write. |
pdf.template.create | POST /v1/pdf/template/create | Create a reusable HTML PDF template; idempotent write. |
pdf.template.delete | DELETE /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.get | GET /v1/pdf/template/get/{template_id} | Retrieve a PDF template's details by template_id. |
pdf.template.list | GET /v1/pdf/template/list | List PDF templates with cursor-based pagination. |
pdf.verify | POST /v1/pdf/verify | Verify a signed PDF's signature validity against a certificate; read-only, no side effects. |
pdf.watermark | POST /v1/pdf/watermark | Stamp a text and/or image watermark onto a PDF; idempotent write. |
End-to-end example
A production-style walkthrough of this module: configure once, then run the flow. It exercises most of the module's APIs.
一次性前置(每个范例都假定已完成):
# 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_..."# 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": "..."}'