Nutrient ドキュメント処理
注意: このスキルはNutrientの商用APIと連携します。使用前に利用規約をご確認ください。
Nutrient DWS Processor APIを使用してドキュメントを処理します。形式変換、テキストと表の抽出、スキャン文書のOCR、個人情報の編集、透かしの追加、デジタル署名、PDFフォームの入力が可能です。
セットアップ
**nutrient.io**で無料APIキーを取得してください。
export NUTRIENT_API_KEY="pdf_live_..."
すべてのリクエストは、instructions というJSONフィールドを含むマルチパートPOSTとして https://api.nutrient.io/build に送信します。
操作
ドキュメントの変換
# DOCX → PDF
curl -X POST https://api.nutrient.io/build \
-H "Authorization: Bearer $NUTRIENT_API_KEY" \
-F "[email protected]" \
-F 'instructions={"parts":[{"file":"document.docx"}]}' \
-o output.pdf
# PDF → DOCX
curl -X POST https://api.nutrient.io/build \
-H "Authorization: Bearer $NUTRIENT_API_KEY" \
-F "[email protected]" \
-F 'instructions={"parts":[{"file":"document.pdf"}],"output":{"type":"docx"}}' \
-o output.docx
# HTML → PDF
curl -X POST https://api.nutrient.io/build \
-H "Authorization: Bearer $NUTRIENT_API_KEY" \
-F "[email protected]" \
-F 'instructions={"parts":[{"html":"index.html"}]}' \
-o output.pdf
対応入力形式: PDF, DOCX, XLSX, PPTX, DOC, XLS, PPT, PPS, PPSX, ODT, RTF, HTML, JPG, PNG, TIFF, HEIC, GIF, WebP, SVG, TGA, EPS。
テキストとデータの抽出
# プレーンテキストの抽出
curl -X POST https://api.nutrient.io/build \
-H "Authorization: Bearer $NUTRIENT_API_KEY" \
-F "[email protected]" \
-F 'instructions={"parts":[{"file":"document.pdf"}],"output":{"type":"text"}}' \
-o output.txt
# 表をExcelとして抽出
curl -X POST https://api.nutrient.io/build \
-H "Authorization: Bearer $NUTRIENT_API_KEY" \
-F "[email protected]" \
-F 'instructions={"parts":[{"file":"document.pdf"}],"output":{"type":"xlsx"}}' \
-o tables.xlsx
スキャン文書のOCR
# OCRで検索可能なPDFに変換(100以上の言語に対応)
curl -X POST https://api.nutrient.io/build \
-H "Authorization: Bearer $NUTRIENT_API_KEY" \
-F "[email protected]" \
-F 'instructions={"parts":[{"file":"scanned.pdf"}],"actions":[{"type":"ocr","language":"english"}]}' \
-o searchable.pdf
言語: ISO 639-2コード(例: eng, deu, fra, spa, jpn, kor, chi_sim, chi_tra, ara, hin, rus)または english や german のような言語名で指定可能。対応言語の完全なリストはOCR言語テーブルをご覧ください。
機密情報の編集
# パターンベース(SSN、メールアドレス)
curl -X POST https://api.nutrient.io/build \
-H "Authorization: Bearer $NUTRIENT_API_KEY" \
-F "[email protected]" \
-F 'instructions={"parts":[{"file":"document.pdf"}],"actions":[{"type":"redaction","strategy":"preset","strategyOptions":{"preset":"social-security-number"}},{"type":"redaction","strategy":"preset","strategyOptions":{"preset":"email-address"}}]}' \
-o redacted.pdf
# 正規表現ベース
curl -X POST https://api.nutrient.io/build \
-H "Authorization: Bearer $NUTRIENT_API_KEY" \
-F "[email protected]" \
-F 'instructions={"parts":[{"file":"document.pdf"}],"actions":[{"type":"redaction","strategy":"regex","strategyOptions":{"regex":"\\b[A-Z]{2}\\d{6}\\b"}}]}' \
-o redacted.pdf
プリセット: social-security-number, email-address, credit-card-number, international-phone-number, north-american-phone-number, date, time, url, ipv4, ipv6, mac-address, us-zip-code, vin。
透かしの追加
curl -X POST https://api.nutrient.io/build \
-H "Authorization: Bearer $NUTRIENT_API_KEY" \
-F "[email protected]" \
-F 'instructions={"parts":[{"file":"document.pdf"}],"actions":[{"type":"watermark","text":"CONFIDENTIAL","fontSize":72,"opacity":0.3,"rotation":-45}]}' \
-o watermarked.pdf
デジタル署名
# 自己署名CMS署名
curl -X POST https://api.nutrient.io/build \
-H "Authorization: Bearer $NUTRIENT_API_KEY" \
-F "[email protected]" \
-F 'instructions={"parts":[{"file":"document.pdf"}],"actions":[{"type":"sign","signatureType":"cms"}]}' \
-o signed.pdf
PDFフォームの入力
curl -X POST https://api.nutrient.io/build \
-H "Authorization: Bearer $NUTRIENT_API_KEY" \
-F "[email protected]" \
-F 'instructions={"parts":[{"file":"form.pdf"}],"actions":[{"type":"fillForm","formFields":{"name":"Jane Smith","email":"[email protected]","date":"2026-02-06"}}]}' \
-o filled.pdf
MCPサーバー(代替手段)
curlの代わりにネイティブツール統合を使用する場合は、MCPサーバーを利用します。
{
"mcpServers": {
"nutrient-dws": {
"command": "npx",
"args": ["-y", "@nutrient-sdk/dws-mcp-server"],
"env": {
"NUTRIENT_DWS_API_KEY": "YOUR_API_KEY",
"SANDBOX_PATH": "/path/to/working/directory"
}
}
}
}
使用すべきケース
- ドキュメントの形式変換(PDF, DOCX, XLSX, PPTX, HTML, 画像)
- PDFからのテキスト、表、キーと値のペアの抽出
- スキャン文書や画像のOCR
- ドキュメント共有前のPII編集
- 下書きや機密文書への透かし追加
- 契約書や同意書へのデジタル署名
- プログラムによるPDFフォームの入力