Skip to content

PDF

Generate, merge, split, OCR and watermark PDFs.

Overview

Base path: https://api.infrai.cc/v1/pdf
Auth header: 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"

Methods

pdf.generate

POST /v1/pdf/generate

Generate a PDF from HTML, a URL or a template.

Parameters

NameTypeRequiredDescription
htmlstringOptionalHTML source to render.
urlstringOptionalSource URL to render or operate on.
template_idstringOptionalTemplate id to render instead of a body.
format"A4" | "Letter" | "Legal"OptionalPage size.
orientation"portrait" | "landscape"OptionalPage orientation.
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

PdfResult { pdf_url, bytes, pages }

Example

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

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

Merge several PDFs into one.

Parameters

NameTypeRequiredDescription
urlsstring[]
Required
List of PDF URLs to merge.

Returns

PdfResult

Example

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

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

Split a PDF by page ranges.

Parameters

NameTypeRequiredDescription
urlstring
Required
Source URL to render or operate on.
rangesstring[]
Required
Page ranges, e.g. 1-3.

Returns

{ parts: PdfResult[] }

Example

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

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

Extract text from a PDF via OCR.

Parameters

NameTypeRequiredDescription
urlstring
Required
Source URL to render or operate on.
languagestringOptionalLanguage hint, e.g. en or zh.

Returns

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

Example

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

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

Apply a text or image watermark to a PDF.

Parameters

NameTypeRequiredDescription
urlstring
Required
Source URL to render or operate on.
textstringOptionalWatermark text.
opacitynumberOptionalWatermark opacity from 0 to 1.

Returns

PdfResult

Example

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

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 用于重试去重。

Parameters

NameTypeRequiredDescription
pdfstring
Required
PDF 输入:URL、base64 数据或已存储的 pdf_id。
mode"fast" | "balanced" | "quality"Optional压缩力度与保真的权衡,复用全局处理档位(fast/balanced/quality)。
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

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

Example

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

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;幂等写入。

Parameters

NameTypeRequiredDescription
pdfstring
Required
PDF 输入:URL、base64 数据或已存储的 pdf_id。
tostring
Required
目标格式(如 docx、png、jpg 等)。
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

PdfDocument (multi-page image targets return PdfDocumentListResult)

Example

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

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。

Parameters

NameTypeRequiredDescription
pdfstring
Required
PDF 输入:URL、base64 数据或已存储的 pdf_id。
pagesnumber[]Optional限定解析的页码(1 起始);省略则解析全部页面。

Returns

PdfParseResult { text, pages, outline, metadata }

Example

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

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 形式返回;只读无副作用。

Parameters

NameTypeRequiredDescription
pdfstring
Required
PDF 输入:URL、base64 数据或已存储的 pdf_id。
pagesnumber[]Optional限定提取图片的页码(1 起始);省略则提取全部页面。

Returns

PdfExtractImagesResult { images: ExtractedImage[] }

Example

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

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 表单字段名与取值;只读无副作用。

Parameters

NameTypeRequiredDescription
pdfstring
Required
PDF 输入:URL、base64 数据或已存储的 pdf_id。

Returns

PdfFormExtractResult { fields }

Example

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

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 用于重试去重。

Parameters

NameTypeRequiredDescription
pdfstring
Required
PDF 输入:URL、base64 数据或已存储的 pdf_id。
fieldsRecord<string, string>
Required
字段名到取值的映射,用于填充表单。
flattenbooleanOptional为 true 时将填充值压平,使表单不可再编辑。
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

PdfDocument { pdf_id, url, page_count, source }

Example

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

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 用于重试去重。

Parameters

NameTypeRequiredDescription
pdfstring
Required
PDF 输入:URL、base64 数据或已存储的 pdf_id。
user_passwordstringOptional打开文档所需的用户密码。
owner_passwordstringOptional用于权限控制的所有者密码。
permissionsstring[]Optional允许的操作权限列表(如 print、copy 等)。
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

PdfDocument { pdf_id, url, source }

Example

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

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);幂等写入。

Parameters

NameTypeRequiredDescription
pdfstring
Required
PDF 输入:URL、base64 数据或已存储的 pdf_id。
passwordstring
Required
用于解密文档的密码。
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

PdfDocument { pdf_id, url, source }

Example

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

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;幂等写入。

Parameters

NameTypeRequiredDescription
pdfstring
Required
PDF 输入:URL、base64 数据或已存储的 pdf_id。
degrees0 | 90 | 180 | 270Optional旋转角度,取值 0、90、180 或 270。
pagesnumber[]Optional限定旋转的页码(1 起始);省略则旋转全部页面。
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

PdfDocument { pdf_id, url, source }

Example

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

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 用于重试去重。

Parameters

NameTypeRequiredDescription
pdfstring
Required
PDF 输入:URL、base64 数据或已存储的 pdf_id。
regionsArray<{ page; x; y; width; height }>Optional需涂黑的矩形区域列表(含页码与坐标尺寸)。
patternsstring[]Optional用于匹配并涂黑敏感内容的正则模式列表。
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

PdfDocument { pdf_id, url, source }

Example

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

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;幂等写入。

Parameters

NameTypeRequiredDescription
pdfstring
Required
PDF 输入:URL、base64 数据或已存储的 pdf_id。
cert_pemstring
Required
签名证书的 PEM 文本(须含有效 PEM 头)。
key_pemstring
Required
签名私钥的 PEM 文本(须含有效 PEM 头)。
reasonstringOptional签名原因(可选,写入签名元数据)。
locationstringOptional签名地点(可选,写入签名元数据)。
retention_daysnumberOptional签名产物的保留天数(可选)。
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

SignedPdfDocument { pdf_id, url, signed_at, signer }

Example

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

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 必填。

Parameters

NameTypeRequiredDescription
signed_pdfstring
Required
已签名的 PDF 输入:URL、base64 数据或已存储的 pdf_id。
cert_pemstring
Required
用于校验签名的证书 PEM 文本。

Returns

SignatureVerification { valid, signer, signed_at }

Example

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

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 文档详情。

Parameters

NameTypeRequiredDescription
pdf_idstring
Required
PDF 文档标识符(形如 pdf_…)。

Returns

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

Example

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

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)。

Parameters

NameTypeRequiredDescription
cursorstringOptional上一页返回的不透明游标;null 表示第一页。
limitnumberOptional单页返回数量,默认 50,范围 1-200。

Returns

PdfDocumentListResult { items: PdfDocument[], next_cursor }

Example

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

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;幂等写入。

Parameters

NameTypeRequiredDescription
pdf_idstring
Required
要删除的 PDF 文档标识符(形如 pdf_…)。
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

{ deleted: boolean, pdf_id }

Example

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

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 作业的状态与结果。

Parameters

NameTypeRequiredDescription
job_idstring
Required
异步 PDF 作业标识符。

Returns

PdfJob { job_id, status, result, error }

Example

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

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 用于重试去重。

Parameters

NameTypeRequiredDescription
namestring
Required
模板名称。
htmlstring
Required
模板的 HTML 内容,可含变量占位符。
vars_schemaobjectOptional模板变量的 JSON Schema(可选),用于校验渲染入参。
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

PdfTemplate { template_id, name, created_at }

Example

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

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 模板详情。

Parameters

NameTypeRequiredDescription
template_idstring
Required
PDF 模板标识符(形如 tpl_…)。

Returns

PdfTemplate { template_id, name, html, vars_schema }

Example

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

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)。

Parameters

NameTypeRequiredDescription
cursorstringOptional上一页返回的不透明游标;null 表示第一页。
limitnumberOptional单页返回数量,默认 50,范围 1-200。

Returns

PdfTemplateListResult { items: PdfTemplate[], next_cursor }

Example

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

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;幂等写入。

Parameters

NameTypeRequiredDescription
template_idstring
Required
要删除的 PDF 模板标识符(形如 tpl_…)。
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

{ deleted: boolean, template_id }

Example

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

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 产物的保留期策略。

Returns

PdfRetentionPolicy { days, hard_max }

Example

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

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)。

Parameters

NameTypeRequiredDescription
daysnumber
Required
产物保留天数(1-90)。
confirmationbooleanOptional设置超过 30 天的较长窗口时必须为 true(成本/合规确认)。
idempotency_keystringOptionalOptional dedup key; identical retries return the same result.

Returns

PdfRetentionPolicy { days, hard_max }

Example

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

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}'

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.

CapabilityEndpointDescription
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.

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.

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

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": "..."}'