document-processor-api
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseNutrient Document Processing
Nutrient 文档处理
Use Nutrient DWS for managed document workflows where fidelity, compliance, or multi-step processing matters more than local-tool convenience.
当保真度、合规性或多步骤处理比本地工具便利性更重要时,使用Nutrient DWS进行托管文档工作流。
Setup
设置
- Get a Nutrient DWS API key at https://dashboard.nutrient.io/sign_up/?product=processor.
- Direct API calls use .
Authorization: Bearer $NUTRIENT_API_KEYbashexport NUTRIENT_API_KEY="nutr_sk_..." - MCP setups commonly use with
@nutrient-sdk/dws-mcp-server.NUTRIENT_DWS_API_KEY - Scripts live in relative to this SKILL.md. Use the directory containing this SKILL.md as the working directory:
scripts/bashcd <directory containing this SKILL.md> && uv run scripts/<script>.py --help - Page ranges use with 0-based indexes and end-exclusive semantics. Negative indexes count from the end.
start:end
- 在https://dashboard.nutrient.io/sign_up/?product=processor获取Nutrient DWS API密钥。
- 直接API调用使用 。
Authorization: Bearer $NUTRIENT_API_KEYbashexport NUTRIENT_API_KEY="nutr_sk_..." - MCP设置通常结合使用
NUTRIENT_DWS_API_KEY。@nutrient-sdk/dws-mcp-server - 脚本位于本SKILL.md相对路径的目录下。将包含本SKILL.md的目录作为工作目录:
scripts/bashcd <directory containing this SKILL.md> && uv run scripts/<script>.py --help - 页面范围使用格式,采用0起始索引且不包含结束索引。负索引从文档末尾开始计数。
start:end
When to use
使用场景
- Generate PDFs from HTML templates, uploaded assets, or remote URLs.
- Convert Office, HTML, image, and PDF files between supported formats.
- OCR scans and extract text, tables, or key-value pairs.
- Redact PII, watermark, sign, fill forms, merge, split, rotate, flatten, or encrypt PDFs.
- Produce delivery targets like PDF/A, PDF/UA, optimized PDFs, or linearized PDFs.
- Check credits before large, batch, or AI-heavy runs.
- 从HTML模板、上传资源或远程URL生成PDF。
- 在支持的格式之间转换Office、HTML、图片和PDF文件。
- 对扫描件进行OCR识别,并提取文本、表格或键值对。
- 对PDF进行PII脱敏、添加水印、数字签名、填写表单、合并、拆分、旋转、扁平化或加密。
- 生成PDF/A、PDF/UA、优化PDF或线性化PDF等交付格式。
- 在执行大规模、批量或AI密集型任务前检查可用额度。
Tool preference
工具优先级
- Prefer for covered single-operation workflows.
scripts/*.py - Use for multi-step jobs that should still run through the Python client.
assets/templates/custom-workflow-template.py - Use the modular docs and direct API payloads for capabilities that do not yet have a dedicated helper script, especially HTML/URL generation and compliance tuning.
references/ - Use local PDF utilities only for lightweight inspection. Use Nutrient when output fidelity or compliance matters.
- 对于已覆盖的单操作工作流,优先使用脚本。
scripts/*.py - 对于多步骤任务,若仍需通过Python客户端运行,使用。
assets/templates/custom-workflow-template.py - 对于尚无专用辅助脚本的功能(尤其是HTML/URL生成和合规性调优),使用模块化的文档和直接API负载。
references/ - 仅将本地PDF工具用于轻量级检查。当输出保真度或合规性很重要时,使用Nutrient。
Single-operation scripts
单操作脚本
- -> convert between
convert.py,pdf,pdfa,pdfua,docx,xlsx,pptx,png,jpeg,webp, andhtmlmarkdown - -> merge multiple files into one PDF
merge.py - -> split one PDF into multiple PDFs by page ranges
split.py - -> append blank pages
add-pages.py - -> remove specific pages
delete-pages.py - -> reorder or duplicate pages into a new PDF
duplicate-pages.py - -> rotate selected pages
rotate.py - -> OCR scanned PDFs or images
ocr.py - -> extract text to JSON
extract-text.py - -> extract tables
extract-table.py - -> extract key-value pairs
extract-key-value-pairs.py - -> apply a text watermark
watermark-text.py - -> detect and apply AI-powered redactions
redact-ai.py - -> digitally sign a local PDF
sign.py - -> write encrypted output PDFs
password-protect.py - -> apply optimization and linearization-style options via JSON
optimize.py
- -> 在
convert.py、pdf、pdfa、pdfua、docx、xlsx、pptx、png、jpeg、webp和html格式之间转换markdown - -> 将多个文件合并为单个PDF
merge.py - -> 按页面范围将单个PDF拆分为多个PDF
split.py - -> 添加空白页
add-pages.py - -> 删除指定页面
delete-pages.py - -> 重新排序或复制页面以生成新PDF
duplicate-pages.py - -> 旋转选定页面
rotate.py - -> 对扫描PDF或图片进行OCR识别
ocr.py - -> 将文本提取为JSON格式
extract-text.py - -> 提取表格
extract-table.py - -> 提取键值对
extract-key-value-pairs.py - -> 添加文本水印
watermark-text.py - -> 检测并应用AI驱动的脱敏处理
redact-ai.py - -> 对本地PDF进行数字签名
sign.py - -> 生成加密的输出PDF
password-protect.py - -> 通过JSON应用优化和线性化类选项
optimize.py
Multi-Step Workflow Rule
多步骤工作流规则
Do not add new committed pipeline scripts under .
scripts/When the user asks for multiple operations in one run:
- Copy to a temporary location such as
assets/templates/custom-workflow-template.py./tmp/ndp-workflow-<task>.py - Implement the combined workflow in that temporary script.
- Run it with .
uv run /tmp/ndp-workflow-<task>.py ... - Return generated output files.
- Delete the temporary script unless the user explicitly asks to keep it.
不要在目录下添加新的已提交管道脚本。
scripts/当用户要求在一次运行中执行多个操作时:
- 将复制到临时位置,例如
assets/templates/custom-workflow-template.py。/tmp/ndp-workflow-<task>.py - 在该临时脚本中实现组合工作流。
- 使用运行脚本。
uv run /tmp/ndp-workflow-<task>.py ... - 返回生成的输出文件。
- 除非用户明确要求保留,否则删除临时脚本。
PDF Requirements
PDF要求
- requires a multi-page PDF and cannot extract ranges from a single-page document.
split.py - must retain at least one page and cannot delete the entire document.
delete-pages.py - only accepts local file paths for the main PDF.
sign.py
- 需要多页PDF,无法从单页文档中提取页面范围。
split.py - 必须至少保留一页,不能删除整个文档。
delete-pages.py - 仅接受主PDF的本地文件路径。
sign.py
Decision rules
决策规则
- Prefer a helper script when one already covers the requested operation cleanly.
- If you control the source markup, prefer HTML generation over browser print workflows.
- Use remote inputs when the source already lives at a stable URL and you want to avoid local uploads.
file.url - Use for conversion and finalization targets. Use
output.typefor transformations when building direct API payloads.actions - OCR before text extraction, key-value extraction, or semantic redaction on scans.
- Prefer preset or regex redaction when the target is explicit. Use AI redaction only for contextual or natural-language requests.
- Use the PDF manipulation reference for merge, split, rotate, flatten, and page-range workflows instead of inferring those payloads from conversion examples.
- Treat PDF/A and PDF/UA as compliance targets, not cosmetic export formats. Choose the target up front and validate final artifacts when requirements are contractual.
- For PDF/UA, clean born-digital inputs and structured HTML usually tag better than rasterized or flattened source PDFs.
- For delivery optimization, linearize or optimize unsigned output artifacts instead of mutating already signed files.
- When the user asks for multiple steps, keep destructive or final steps late in the sequence. Use the workflow recipes when ordering is ambiguous.
- 如果已有辅助脚本能清晰覆盖请求的操作,优先使用该脚本。
- 如果您控制源标记,优先使用HTML生成而非浏览器打印工作流。
- 当源文件已存储在稳定URL且您希望避免本地上传时,使用远程输入。
file.url - 转换和最终化目标使用。构建直接API负载时,使用
output.type进行转换操作。actions - 对扫描件进行文本提取、键值提取或语义脱敏前,先执行OCR识别。
- 当目标明确时,优先使用预设或正则表达式脱敏。仅在处理上下文或自然语言请求时使用AI脱敏。
- 对于合并、拆分、旋转、扁平化和页面范围工作流,使用PDF操作参考文档,而非从转换示例中推断负载。
- 将PDF/A和PDF/UA视为合规目标,而非美化导出格式。提前选择目标格式,当要求具有合约性质时,验证最终产物。
- 对于PDF/UA,原生数字输入和结构化HTML通常比光栅化或扁平化的源PDF标记效果更好。
- 针对交付优化,对未签名的输出产物进行线性化或优化,而非修改已签名文件。
- 当用户要求多个步骤时,将破坏性或最终步骤放在序列后期。当顺序不明确时,使用工作流配方。
Anti-patterns
反模式
- Do not OCR born-digital PDFs just because the task mentions extraction. Extract first and OCR only if the text layer is missing.
- Do not flatten forms or annotations until the user confirms the artifact no longer needs to stay editable.
- Do not sign, archive, or linearize intermediate working files. Keep those as final-delivery steps.
- Do not promise PDF/A or PDF/UA compliance without a validation step when the requirement is contractual.
- Do not commit temporary workflow scripts under .
scripts/
- 不要仅仅因为任务提到提取就对原生数字PDF进行OCR识别。先提取文本,仅当文本层缺失时再进行OCR。
- 除非用户确认产物不再需要保持可编辑状态,否则不要扁平化表单或注释。
- 不要对中间工作文件进行签名、归档或线性化处理。将这些操作保留为最终交付步骤。
- 当合规要求具有合约性质时,不要在未进行验证步骤的情况下承诺PDF/A或PDF/UA合规性。
- 不要将临时工作流脚本提交到目录下。
scripts/
Reference map
参考映射
Read only what you need:
- -> endpoint model, auth, multipart vs JSON, credits, limits, and errors
references/request-basics.md - -> HTML/URL generation and format conversion
references/generation-and-conversion.md - -> merge, split, page-range, rotate, and flatten workflows
references/pdf-manipulation.md - -> OCR, text extraction, tables, and key-value workflows
references/extraction-and-ocr.md - -> redaction, watermarking, signatures, forms, and passwords
references/security-signing-and-forms.md - -> PDF/A, PDF/UA, optimization, and linearization
references/compliance-and-optimization.md - -> end-to-end sequencing patterns for common business document workflows
references/workflow-recipes.md
按需阅读:
- -> 端点模型、认证、多部分表单与JSON、额度、限制和错误
references/request-basics.md - -> HTML/URL生成和格式转换
references/generation-and-conversion.md - -> 合并、拆分、页面范围、旋转和平铺工作流
references/pdf-manipulation.md - -> OCR、文本提取、表格和键值对工作流
references/extraction-and-ocr.md - -> 脱敏、水印、签名、表单和密码
references/security-signing-and-forms.md - -> PDF/A、PDF/UA、优化和线性化
references/compliance-and-optimization.md - -> 常见业务文档工作流的端到端序列模式
references/workflow-recipes.md
Rules
规则
- Fail fast when required arguments are missing.
- Write outputs to explicit paths and print created files.
- Do not log secrets.
- All client methods are async and should run via .
asyncio.run(main()) - If import fails, install dependency with .
uv add nutrient-dws
- 当缺少必要参数时快速失败。
- 将输出写入明确路径并打印已创建的文件。
- 不要记录机密信息。
- 所有客户端方法均为异步,应通过运行。
asyncio.run(main()) - 如果导入失败,使用安装依赖。
uv add nutrient-dws
Security Hardening Addendum
安全加固补充说明
- Prefer a pinned, preinstalled MCP server binary over runtime package fetches.
- Preferred:
npm i -g @nutrient-sdk/dws-mcp-server@<pinned-version> - Avoid unpinned runtime fetch in production paths.
- Preferred:
- Never store in committed JSON config files.
NUTRIENT_DWS_API_KEY- Use process env injection at runtime (shell/export, secrets manager, or host env).
- Restrict file access with to the minimum required working directory.
SANDBOX_PATH - Before enabling MCP mode in production, verify package provenance and lock version.
- 优先使用固定版本的预安装MCP服务器二进制文件,而非运行时包获取。
- 推荐:
npm i -g @nutrient-sdk/dws-mcp-server@<pinned-version> - 避免在生产路径中使用未固定版本的运行时获取。
- 推荐:
- 不要将存储在已提交的JSON配置文件中。
NUTRIENT_DWS_API_KEY- 在运行时通过进程环境注入(shell/export、密钥管理器或主机环境)。
- 使用限制文件访问至所需的最小工作目录。
SANDBOX_PATH - 在生产环境中启用MCP模式前,验证包来源并锁定版本。