跳转到主要内容

PDF Tools API

PDF 脱敏 API

在后端、批处理或产品流程中给 PDF 区域脱敏,不必自己维护 PDF 处理基础设施;成功请求按 Credits 计费。

Credits

1 Credit / call

1 Credit per successful API request. Failed processing attempts are refunded automatically.

Pricing

1,000 Credits = $1

Every signed-in user receives 100 free API Credits each month.

Endpoint

/api/external/pdf-tools/pdf-redaction

Use your API Key in the x-api-key header.

Use case

适合在合规复核后遮盖身份证号、金额、客户信息或内部备注。网页工具用于人工处理,API 用于稳定的服务端自动化。

cURL example

curl -X POST https://itextmaster.com/api/external/pdf-tools/pdf-redaction \
  -H 'x-api-key: YOUR_API_KEY' \
  -F 'file=@input.pdf;type=application/pdf' \
  -F 'options={"areas":[{"page":1,"x":72,"y":120,"width":180,"height":36,"replacementText":"REDACTED"}],"color":{"r":0,"g":0,"b":0}}' \
  --output redacted.pdf

Multipart example

curl -X POST https://itextmaster.com/api/external/pdf-tools/pdf-redaction \
  -H 'x-api-key: YOUR_API_KEY' \
  -F 'file=@input.pdf;type=application/pdf' \
  -F 'options={"areas":[{"page":1,"x":72,"y":120,"width":180,"height":36,"replacementText":"REDACTED"}],"color":{"r":0,"g":0,"b":0}}' \
  --output redacted.pdf

JSON base64 example

curl -X POST https://itextmaster.com/api/external/pdf-tools/pdf-redaction \
  -H 'Content-Type: application/json' \
  -H 'x-api-key: YOUR_API_KEY' \
  -d '{
    "file": { "name": "input.pdf", "dataBase64": "JVBERi0xLjcK..." },
    "options": {"areas":[{"page":1,"x":72,"y":120,"width":180,"height":36,"replacementText":"REDACTED"}],"color":{"r":0,"g":0,"b":0}}
  }' \
  --output redacted.pdf

Node.js example

import { writeFile } from 'node:fs/promises';

const response = await fetch('https://itextmaster.com/api/external/pdf-tools/pdf-redaction', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'x-api-key': process.env.ITEXTMASTER_API_KEY
  },
  body: JSON.stringify({
  file: { name: 'input.pdf', dataBase64: 'JVBERi0xLjcK...' },
  options: {"areas":[{"page":1,"x":72,"y":120,"width":180,"height":36,"replacementText":"REDACTED"}],"color":{"r":0,"g":0,"b":0}}
})
});

if (!response.ok) {
  throw new Error(await response.text());
}

await writeFile('redacted.pdf', Buffer.from(await response.arrayBuffer()));

Python example

import os
import requests

response = requests.post(
    'https://itextmaster.com/api/external/pdf-tools/pdf-redaction',
    headers={
        'Content-Type': 'application/json',
        'x-api-key': os.environ['ITEXTMASTER_API_KEY'],
    },
    json={
        'file': {'name': 'input.pdf', 'dataBase64': 'JVBERi0xLjcK...'},
        'options': {'areas': [{'page': 1, 'x': 72, 'y': 120, 'width': 180, 'height': 36, 'replacementText': 'REDACTED'}], 'color': {'r': 0, 'g': 0, 'b': 0}}
    },
)
response.raise_for_status()

with open('redacted.pdf', 'wb') as f:
    f.write(response.content)

Error codes

401invalid_api_key

x-api-key 缺失、无效或已经轮换。

402insufficient_credits

账号 API Credits 不足。

422pdf_tool_processing_failed

文件、参数或 PDF 结构无法处理;失败处理会自动退回 Credits。

Limits

  • 需要可正常打开的 PDF 或有效输入数据。
  • 请从服务端调用 API,不要在浏览器暴露 API Key。
  • 复杂文件建议先用代表性样本测试输出质量。

Response headers

redacted.pdf,响应头会返回本次消耗的 Credits 和剩余额度。

Content-Type
生成文件的 MIME 类型,通常是 application/pdf 或 application/zip。
Content-Disposition
生成文件的下载文件名。
X-Credits-Charged
成功请求实际扣除的 Credits。
X-Credit-Balance
请求完成后的剩余 API Credits。

FAQ

PDF 脱敏 API 怎么计费?

成功的 PDF 脱敏 API 请求会消耗 API Credits;失败处理会自动退回。每个登录用户每月有 100 个免费 API Credits,1,000 Credits = $1。

网站工具会消耗 API Credits 吗?

浏览器本地处理的网站工具不消耗 API Credits;只有通过 API Key 发起的自动化请求才按 Credits 计费。

可以从前端直接调用吗?

不建议。API Key 应保存在服务端、队列任务或自动化脚本中。

Start with 100 free API Credits

Create an API Key, test PDF 脱敏 API, and buy more Credits only when automation volume grows.

iTextMaster

专业PDF工具 - 免费且私密

安全

  • 本地优先处理大多数文件工具在浏览器中运行。
  • 服务端处理清晰提示需要服务端处理的工具会在提交前明确说明。

选择语言

© 2026 iTextMaster. © iTextMaster. 保留所有权利。