jpskill.com
📄 ドキュメント コミュニティ

pdf-toolkit

PDFファイルからテキストや画像、表を抽出したり、スキャンされたPDFをOCR処理したり、テキストや画像からPDFを作成したり、PDFの結合や分割など、PDFに関する様々な処理をJSON形式で実行するSkill。

📜 元の英語説明(参考)

Extract text, tables, and images from PDFs, OCR scanned PDFs, create PDFs from text/images/markdown, and merge or split PDF files. Use when working with PDF documents, when the user mentions PDFs, document extraction, OCR, scanning, PDF merging, splitting, combining, or creating PDF reports. All operations use bundled Bun TypeScript scripts with structured JSON output.

🇯🇵 日本人クリエイター向け解説

一言でいうと

PDFファイルからテキストや画像、表を抽出したり、スキャンされたPDFをOCR処理したり、テキストや画像からPDFを作成したり、PDFの結合や分割など、PDFに関する様々な処理をJSON形式で実行するSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o pdf-toolkit.zip https://jpskill.com/download/9143.zip && unzip -o pdf-toolkit.zip && rm pdf-toolkit.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/9143.zip -OutFile "$d\pdf-toolkit.zip"; Expand-Archive "$d\pdf-toolkit.zip" -DestinationPath $d -Force; ri "$d\pdf-toolkit.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して pdf-toolkit.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → pdf-toolkit フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

PDF Toolkit

PDFからのデータ抽出(テキスト、テーブル、画像、OCR)、新規PDFの作成、既存PDFの操作(結合、分割)を行います。すべての操作は、構造化されたJSON出力を生成する、バンドルされたBun TypeScriptスクリプトを使用します。

どのような時に使うか

  • PDFファイルからテキスト、テーブル、または画像を抽出する場合
  • スキャンされたPDFまたは画像ベースのPDFをOCR処理する場合
  • テキスト、Markdown、または画像から新しいPDFを作成する場合
  • 複数のPDFを1つに結合する場合
  • PDFを個別のファイルに分割する場合(ページごと、範囲ごと、またはチャンクごと)
  • ユーザーが「PDF」、「ドキュメント抽出」、または「スキャンされたドキュメント」について言及した場合

使用すべきでない場合:

  • Word(.docx)、Excel(.xlsx)、またはその他の非PDF形式を扱う場合
  • ユーザーがインタラクティブなPDFフォームへの入力を必要とする場合(サポートされていません)
  • ユーザーがPDFの暗号化またはデジタル署名を必要とする場合

前提条件

すべてのスクリプトにはBunが必要です。依存関係は初回実行時に自動的にインストールされます。

ワークフロー

1. 操作の特定

ユーザーのニーズに基づいて、使用するスクリプトを決定します。

ニーズ スクリプト
PDFからテキストを抽出する scripts/extract-text.ts
テーブルを構造化されたデータとして抽出する scripts/extract-tables.ts
PDFから画像を抽出する scripts/extract-images.ts
スキャンされた/画像ベースのPDFをOCR処理する scripts/ocr-pdf.ts
新しいPDFを作成する scripts/create-pdf.ts
複数のPDFを結合する scripts/merge-pdf.ts
PDFを分割する scripts/split-pdf.ts

extract-textとocr-pdfのどちらを選ぶか: PDFに選択可能なテキストが含まれている場合(コピー&ペーストできる場合)は、extract-text.tsを使用します。PDFがスキャンまたは画像である場合(テキストが画像に埋め込まれている場合)は、ocr-pdf.tsを使用します。不明な場合は、最初にextract-text.tsを試してください。空または文字化けしたテキストが返された場合は、ocr-pdf.tsにフォールバックします。

2. スクリプトの実行

すべてのスクリプトは同じ規則に従います。

bun run scripts/<script>.ts [options] <input-file>
  • JSON出力はstdoutに出力されます(エージェントによる解析が可能)
  • 進捗状況と診断はstderrに出力されます
  • 終了コード0 = 成功、1 = エラー
  • すべてのスクリプトは、完全な使用法のために--helpをサポートしています

3. 出力の処理

ダウンストリームで使用するためにJSON出力を解析します。すべてのスクリプトは、一貫したパターン(ファイルメタデータ、ページレベルの結果、サマリーカウント)を持つ構造化されたJSONを返します。

スクリプトリファレンス

extract-text.ts — テキスト抽出

# PDFからすべてのテキストを取得
bun run scripts/extract-text.ts document.pdf

# 特定のページをJSONとして取得
bun run scripts/extract-text.ts --pages 1,3,5-7 --format json report.pdf

# ページごとのテキストをファイルに出力
bun run scripts/extract-text.ts --per-page --output out.txt slides.pdf
フラグ デフォルト 説明
--pages all ページ選択(例:1,3,5-7
--format text 出力形式:textまたはjson
--per-page off ページごとに個別に出力
--output stdout 出力ファイルパス

テキスト抽出にunpdfを使用します。埋め込みテキストレイヤーを持つPDFで動作します。スキャンされたPDFの場合は、代わりにocr-pdf.tsを使用してください。

extract-tables.ts — テーブル抽出

# すべてのテーブルをJSONとして抽出
bun run scripts/extract-tables.ts report.pdf

# 特定のページのテーブルをCSVとして抽出
bun run scripts/extract-tables.ts --pages 2,3 --format csv data.pdf
フラグ デフォルト 説明
--pages all ページ選択
--format json 出力形式:jsoncsv、またはtsv
--output stdout 出力ファイルパス

区切り文字パターン(タブ区切り、パイプ区切り(|)、および複数スペース区切り)でテーブルを検出します。ヘッダーと行を含む構造化されたデータを返します。

extract-images.ts — 画像抽出

# すべての画像をPNGとして抽出
bun run scripts/extract-images.ts document.pdf

# 1〜3ページからJPEGとして、最小100pxで抽出
bun run scripts/extract-images.ts --pages 1-3 --format jpeg --min-size 100 brochure.pdf

# 保存せずに画像を一覧表示
bun run scripts/extract-images.ts --list-only slides.pdf
フラグ デフォルト 説明
--pages all ページ選択
--output-dir ./extracted-images/ 画像の保存場所
--format png 画像形式:pngまたはjpeg
--min-size 50 最小寸法(ピクセル単位)
--list-only off 保存せずに一覧表示

mupdf WASMを使用して画像XObjectを抽出します。個別の画像を抽出できない場合は、288 DPIでフルページレンダリングにフォールバックします。

ocr-pdf.ts — スキャンされたPDFのOCR

# スキャンされたPDFをOCR処理
bun run scripts/ocr-pdf.ts scanned-doc.pdf

# ドイツ語で、高DPIで特定のページをOCR処理
bun run scripts/ocr-pdf.ts --pages 1-5 --lang deu --dpi 600 scan.pdf

# 信頼度スコア付きのJSON出力
bun run scripts/ocr-pdf.ts --format json --output result.json scanned.pdf
フラグ デフォルト 説明
--pages all ページ選択
--format text 出力形式:textまたはjson
--lang eng Tesseract言語コード
--dpi 300 レンダリングDPI(高いほどOCR精度が向上)
--confidence-threshold 30 最小単語信頼度(0〜100)
--output stdout 出力ファイルパス

mupdfを介してページをレンダリングし、tesseract.jsでOCR処理します。

📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

PDF Toolkit

Extract data from PDFs (text, tables, images, OCR), create new PDFs, and manipulate existing ones (merge, split). All operations use bundled Bun TypeScript scripts that produce structured JSON output.

When to use

  • When extracting text, tables, or images from PDF files
  • When OCR-ing scanned PDFs or image-based PDFs
  • When creating new PDFs from text, markdown, or images
  • When merging multiple PDFs into one
  • When splitting a PDF into separate files (by page, range, or chunk)
  • When the user mentions "PDF", "document extraction", or "scanned document"

Do NOT use when:

  • Working with Word (.docx), Excel (.xlsx), or other non-PDF formats
  • The user needs interactive PDF form filling (not supported)
  • The user needs PDF encryption or digital signatures

Prerequisites

All scripts require Bun. Dependencies are auto-installed on first run.

Workflow

1. Identify the operation

Determine which script to use based on what the user needs:

Need Script
Extract text from PDF scripts/extract-text.ts
Extract tables as structured data scripts/extract-tables.ts
Extract images from PDF scripts/extract-images.ts
OCR a scanned/image-based PDF scripts/ocr-pdf.ts
Create a new PDF scripts/create-pdf.ts
Merge multiple PDFs scripts/merge-pdf.ts
Split a PDF into parts scripts/split-pdf.ts

How to choose between extract-text and ocr-pdf: If the PDF contains selectable text (you can copy-paste from it), use extract-text.ts. If the PDF is a scan or image (text is embedded in images), use ocr-pdf.ts. When unsure, try extract-text.ts first — if it returns empty or garbled text, fall back to ocr-pdf.ts.

2. Run the script

All scripts follow the same conventions:

bun run scripts/<script>.ts [options] <input-file>
  • JSON output goes to stdout (parseable by agents)
  • Progress and diagnostics go to stderr
  • Exit code 0 = success, 1 = error
  • All scripts support --help for full usage

3. Process the output

Parse the JSON output for downstream use. All scripts return structured JSON with consistent patterns (file metadata, page-level results, summary counts).

Script Reference

extract-text.ts — Text extraction

# All text from a PDF
bun run scripts/extract-text.ts document.pdf

# Specific pages as JSON
bun run scripts/extract-text.ts --pages 1,3,5-7 --format json report.pdf

# Per-page text to a file
bun run scripts/extract-text.ts --per-page --output out.txt slides.pdf
Flag Default Description
--pages all Page selection (e.g., 1,3,5-7)
--format text Output format: text or json
--per-page off Separate output by page
--output stdout Output file path

Uses unpdf for text extraction. Works with PDFs that have embedded text layers. For scanned PDFs, use ocr-pdf.ts instead.

extract-tables.ts — Table extraction

# Extract all tables as JSON
bun run scripts/extract-tables.ts report.pdf

# Extract tables from specific pages as CSV
bun run scripts/extract-tables.ts --pages 2,3 --format csv data.pdf
Flag Default Description
--pages all Page selection
--format json Output format: json, csv, or tsv
--output stdout Output file path

Detects tables by delimiter patterns: tab-separated, pipe-separated (|), and multi-space-separated. Returns structured data with headers and rows.

extract-images.ts — Image extraction

# Extract all images as PNG
bun run scripts/extract-images.ts document.pdf

# Extract from pages 1-3 as JPEG, min 100px
bun run scripts/extract-images.ts --pages 1-3 --format jpeg --min-size 100 brochure.pdf

# List images without saving
bun run scripts/extract-images.ts --list-only slides.pdf
Flag Default Description
--pages all Page selection
--output-dir ./extracted-images/ Where to save images
--format png Image format: png or jpeg
--min-size 50 Min dimension in pixels
--list-only off List without saving

Uses mupdf WASM to extract image XObjects. Falls back to full-page rendering at 288 DPI when discrete images can't be extracted.

ocr-pdf.ts — OCR for scanned PDFs

# OCR a scanned PDF
bun run scripts/ocr-pdf.ts scanned-doc.pdf

# OCR specific pages in German at high DPI
bun run scripts/ocr-pdf.ts --pages 1-5 --lang deu --dpi 600 scan.pdf

# JSON output with confidence scores
bun run scripts/ocr-pdf.ts --format json --output result.json scanned.pdf
Flag Default Description
--pages all Page selection
--format text Output format: text or json
--lang eng Tesseract language code
--dpi 300 Rendering DPI (higher = better OCR)
--confidence-threshold 30 Min word confidence (0-100)
--output stdout Output file path

Renders pages via mupdf, then OCRs with tesseract.js. JSON output includes per-page confidence scores and low-confidence word lists. Common language codes: eng, fra, deu, spa, jpn, chi_sim.

create-pdf.ts — PDF creation

# From plain text
bun run scripts/create-pdf.ts --from-text input.txt --output out.pdf

# From images (one per page)
bun run scripts/create-pdf.ts --from-images "photos/*.png" --output album.pdf

# From markdown
bun run scripts/create-pdf.ts --from-markdown doc.md --output report.pdf --page-size a4
Flag Default Description
--from-text Create from plain text file
--from-images Create from image files (glob pattern)
--from-markdown Create from markdown file
--output required Output PDF path
--page-size letter Page size: letter, a4, legal
--margin 72 Margin in points (72pt = 1 inch)
--font-size 12 Base font size in points
--title Document title metadata
--author Document author metadata

Exactly one of --from-text, --from-images, or --from-markdown must be specified. Uses pdf-lib for PDF generation.

merge-pdf.ts — Merge PDFs

# Merge two PDFs
bun run scripts/merge-pdf.ts --output merged.pdf chapter1.pdf chapter2.pdf

# Merge with page selections (semicolon-separated, one per input)
bun run scripts/merge-pdf.ts --output out.pdf --page-ranges "1-3;all;2-5" a.pdf b.pdf c.pdf
Flag Default Description
--output required Output PDF path
--page-ranges all Per-input page selections (;-separated)
--bookmark off Add source filenames to metadata

Pass two or more input PDFs as positional arguments. They are merged in order. Page ranges use semicolons between inputs: "1-3;all;2-5" means pages 1-3 from the first PDF, all from the second, pages 2-5 from the third.

split-pdf.ts — Split PDF

# One file per page
bun run scripts/split-pdf.ts report.pdf

# Split into 5-page chunks
bun run scripts/split-pdf.ts report.pdf --mode chunks --chunk-size 5 --output-dir ./split/

# Split by custom ranges
bun run scripts/split-pdf.ts report.pdf --mode ranges --ranges "1-3;4-6;7-10"
Flag Default Description
--mode pages Split mode: pages, ranges, chunks
--output-dir . Output directory
--ranges Page ranges for ranges mode
--chunk-size Pages per chunk for chunks mode
--prefix input name Filename prefix for outputs

Checklist

  • [ ] Identified the correct script for the operation
  • [ ] Checked if PDF has selectable text (extract-text) or is scanned (ocr-pdf)
  • [ ] Used --format json when structured output is needed downstream
  • [ ] Verified output file exists and has expected content
  • [ ] For merges: inputs provided in correct order
  • [ ] For splits: verified all output files are present

Common Mistakes

Mistake Fix
Using extract-text on a scanned PDF Use ocr-pdf.ts instead — extract-text returns empty
Forgetting --output on merge-pdf --output is required, not optional
Page ranges in merge use commas between inputs Use semicolons between inputs: "1-3;all;2-5"
OCR returns garbled text Increase --dpi (try 600) or check --lang matches source
extract-images returns nothing Increase --min-size or check pages have actual images
split in ranges mode without --ranges flag --ranges is required when --mode is ranges
Passing glob pattern unquoted to from-images Quote the glob: --from-images "*.png" not *.png

Key Principles

  1. Text before OCR — Always try extract-text.ts first. It's faster and more accurate for PDFs with embedded text. Only use ocr-pdf.ts when extract-text returns empty or garbled output.

  2. JSON for pipelines — Use --format json when the output will be processed by another script or the agent. Use --format text when the output is for human reading.

  3. Page ranges are 1-indexed — All scripts use 1-indexed page numbers in their --pages and --ranges flags. Internally they convert to 0-indexed for the PDF libraries.

  4. Stderr for progress, stdout for data — Never mix diagnostics with output. All scripts write progress to stderr and data to stdout.