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

pdf-page-extract

PDFのページからテキストや画像などの情報を抽出し、それらを整理して保存することで、後の分析や処理に役立てやすくするSkill。

📜 元の英語説明(参考)

Extract rich data from PDF pages including text spans with metadata, rendered PNG images, and page mapping. Creates persistent artifacts for downstream processing.

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

一言でいうと

PDFのページからテキストや画像などの情報を抽出し、それらを整理して保存することで、後の分析や処理に役立てやすくするSkill。

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

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

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

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

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

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して pdf-page-extract.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → pdf-page-extract フォルダができる
  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 Page Extract Skill

目的

この Skill は、正確な AI 駆動の HTML 生成を可能にするために、PDF ページから必要なすべてのデータを抽出します。これは、以下の3つの重要な成果物を生成します。

  1. リッチな抽出データ - フォントメタデータ(サイズ、スタイル、位置)を持つテキストスパン
  2. レンダリングされた PNG 画像 - AI がページレイアウトを理解するための視覚的な参照
  3. ページマッピング - PDF インデックスから書籍ページへの信頼できるマッピング

これは、パイプライン全体の決定論的な、Python ベースの基盤です。抽出されたすべてのデータは、追跡可能性と将来の処理のために永続的なファイルに保存されます。

実行内容

  1. 入力パラメータの検証

    • PDF ファイルが存在し、読み取り可能であることを確認します
    • ページ範囲(PDF インデックスまたは書籍ページ)を検証します
    • 出力ディレクトリ構造を確認します
  2. ページマッピングの確立 (まだ完了していない場合)

    • 実行: python3 Calypso/tools/read_page_footers.py
    • ページフッターをスキャンして、PDF インデックス → 書籍ページのマッピングを確立します
    • 保存先: analysis/page_mapping.json
  3. PyMuPDF と pdfplumber を使用したリッチなページデータの抽出

    • 実行: python3 Calypso/tools/rich_extractor.py
    • フォントメタデータを持つテキストスパンを抽出します:
      • フォント名とサイズ
      • 太字/斜体フラグ
      • 位置(バウンディングボックス)
      • 色情報
    • ページ構造を分析して、以下を識別します:
      • 見出しの可能性が高いもの(サイズとスタイルによる)
      • 段落(通常のテキスト)
      • リストの候補
    • pdfplumber を使用してテーブルを検出します
    • 保存先: analysis/chapter_XX/rich_extraction.json
  4. PDF ページの PNG へのレンダリング

    • ページを高解像度 PNG 画像に変換します (300+ DPI)
    • AI 参照のために視覚的な忠実度を維持します
    • 保存先: output/chapter_XX/page_artifacts/page_YY/02_page_XX.png
  5. 埋め込み画像の抽出 (存在する場合)

    • 実行: python3 Calypso/tools/extract_images.py
    • ページからすべての画像を抽出します
    • 保存先: output/chapter_XX/images/page_YY_image_*.png
    • メタデータを作成します: page_YY_images.json
  6. 抽出の完了の検証

    • すべてのファイルが正しく保存されたことを確認します
    • JSON ファイルが有効であることを確認します
    • PNG 画像が読み取り可能であることを確認します
    • ページマッピングの一貫性を検証します

入力パラメータ

chapter: <int>           - 章番号 (1-8)
start_page: <int>        - 開始 PDF インデックス (0 から始まる) またはページ範囲
end_page: <int>          - 終了 PDF インデックス (単一ページの場合はオプション)
pdf_path: <str>          - PDF ファイルへのパス (デフォルト: Calypso/PREP-AL 4th Ed 9-26-25.pdf)
output_base: <str>       - 出力ディレクトリ (デフォルト: Calypso/output)
mapping_file: <str>      - ページマッピングファイル (デフォルト: Calypso/analysis/page_mapping.json)

出力構造

保存される成果物ファイル

ページごとの成果物 ( output/chapter_XX/page_artifacts/page_YY/ 内):

  • 01_rich_extraction.json - メタデータを持つテキストスパン
  • 02_page_XX.png - レンダリングされた PDF ページ画像
  • page_mapping.json - 共有マッピングファイル (シンボリックリンクまたはコピー)

抽出データ ( analysis/chapter_XX/ 内):

  • rich_extraction.json - 章のすべてのページに対する完全な抽出
  • page_6_pattern_analysis.json - (オプション) 特定のページのパターン分析

画像 ( output/chapter_XX/images/chapter_XX/ 内):

  • page_XX_image_*.png - ページからの埋め込み画像
  • page_XX_images.json - 埋め込み画像のメタデータ

リッチ抽出 JSON 形式

{
  "page_number": 16,
  "pdf_index": 15,
  "book_page": 17,
  "chapter": 2,
  "dimensions": {
    "width": 612,
    "height": 792
  },
  "text_spans": [
    {
      "text": "Rights in Real Estate",
      "font": "Arial-BoldMT",
      "size": 27.04,
      "bold": true,
      "italic": false,
      "bbox": {
        "x0": 72,
        "y0": 150,
        "x1": 400,
        "y1": 177
      },
      "color": 0,
      "sequence": 1
    }
  ],
  "analysis": {
    "font_sizes": {
      "27.04": 1,
      "11.04": 45
    },
    "font_styles": {
      "bold_27.04": 1,
      "regular_11.04": 45
    },
    "likely_headings": [
      {
        "text": "Rights in Real Estate",
        "level": 1,
        "confidence": 0.95
      }
    ],
    "likely_paragraphs": [
      {
        "text": "Real property consists of...",
        "type": "body_text"
      }
    ]
  },
  "extraction_timestamp": "2025-11-08T14:30:00Z",
  "extraction_tool": "rich_extractor.py v1.0"
}

実行する Python コマンド

ステップ 1: ページマッピングの確立

cd Calypso/tools
python3 read_page_footers.py \
  --start 15 \
  --end 28 \
  --pdf "../PREP-AL 4th Ed 9-26-25.pdf" \
  --output "../analysis/page_mapping.json"

成功の指標:

  • コマンドがコード 0 で終了する
  • ページマッピング JSON が作成/更新される
  • 範囲内のすべてのページにエントリがある

ステップ 2: リッチデータの抽出

cd Calypso/tools
python3 rich_extractor.py \
  --pdf "../PREP-AL 4th Ed 9-26-25.pdf" \
  --start 15 \
  --end 28 \
  --output "../analysis/chapter_02/rich_extraction.json"

成功の指標:

  • コマンドがコード 0 で終了する
  • JSON ファイルが作成される
  • ファイルに text_spans 配列が含まれている
  • 範囲内のすべてのページが表現されている

ステップ 3: PNG へのレンダリング

cd Calypso/tools
python3 -c "
import fitz
pdf = fitz.open('../PREP-AL 4th Ed 9-26-25.pdf')
for page_idx in range(15, 29):
    page = pdf[page_idx]
    pix = page.get_pixmap(matrix=fitz.Matrix(3, 3))  # 300% zoom for high-res
    pix.save(f'../output/chapter_02/page_artifacts/page_{page_idx:02d}/02_page_{page_idx}.png')
pdf.close()
"

ステップ 4: 画像の抽出 (存在する場合)

cd Calypso/tools
# 画像のある各ページに対して
python3 extract_images.py \
  --page 17 \
  --pdf "../PREP-AL 4th Ed 9-26-25.pdf" \
  --output "../output" \
  --mapping "../analysis/page_mapping.json"

品質チェック

抽出が完了したと宣言する前に:

  1. ファイルの存在

    • [ ] 01_rich_extraction.json が存在する
    • [ ] 02_page_XX.png が存在し、有効である
    • [ ] page_mapping.json が存在する
  2. JSON の有効性

    • [ ] JSON ファイルがエラーなしで解析される
    • [ ] 必要なフィールドがすべて存在する
    • [ ] 重要なフィールドに null/undefined 値がない
  3. データの完全性

    • [ ] 範囲内のすべてのページに hav
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

PDF Page Extract Skill

Purpose

This skill extracts all necessary data from PDF pages to enable accurate AI-driven HTML generation. It produces three critical artifacts:

  1. Rich extraction data - Text spans with font metadata (sizes, styles, positions)
  2. Rendered PNG image - Visual reference for AI to understand page layout
  3. Page mapping - Authoritative mapping of PDF indices to book pages

This is the deterministic, Python-based foundation for the entire pipeline. All extracted data is saved to persistent files for traceability and future processing.

What to Do

  1. Validate input parameters

    • Check PDF file exists and is readable
    • Verify page range (PDF indices or book pages)
    • Confirm output directory structure
  2. Establish page mapping (if not already done)

    • Run: python3 Calypso/tools/read_page_footers.py
    • Scans page footers to establish PDF index → book page mapping
    • Saves to: analysis/page_mapping.json
  3. Extract rich page data using PyMuPDF and pdfplumber

    • Run: python3 Calypso/tools/rich_extractor.py
    • Extracts text spans with font metadata:
      • Font name and size
      • Bold/italic flags
      • Position (bounding box)
      • Color information
    • Analyzes page structure to identify:
      • Likely headings (by size and style)
      • Paragraphs (regular text)
      • Potential lists
    • Detects tables using pdfplumber
    • Saves to: analysis/chapter_XX/rich_extraction.json
  4. Render PDF page to PNG

    • Convert page to high-resolution PNG image (300+ DPI)
    • Maintains visual fidelity for AI reference
    • Saves to: output/chapter_XX/page_artifacts/page_YY/02_page_XX.png
  5. Extract embedded images (if present)

    • Run: python3 Calypso/tools/extract_images.py
    • Extracts all images from page
    • Saves: output/chapter_XX/images/page_YY_image_*.png
    • Creates metadata: page_YY_images.json
  6. Validate extraction completeness

    • Verify all files saved correctly
    • Check JSON files are valid
    • Confirm PNG image is readable
    • Validate page mapping consistency

Input Parameters

chapter: <int>           - Chapter number (1-8)
start_page: <int>        - Starting PDF index (0-based) or page range
end_page: <int>          - Ending PDF index (optional if single page)
pdf_path: <str>          - Path to PDF file (default: Calypso/PREP-AL 4th Ed 9-26-25.pdf)
output_base: <str>       - Output directory (default: Calypso/output)
mapping_file: <str>      - Page mapping file (default: Calypso/analysis/page_mapping.json)

Output Structure

Artifact Files Saved

Per-page artifacts (in output/chapter_XX/page_artifacts/page_YY/):

  • 01_rich_extraction.json - Text spans with metadata
  • 02_page_XX.png - Rendered PDF page image
  • page_mapping.json - Shared mapping file (symlink or copy)

Extraction data (in analysis/chapter_XX/):

  • rich_extraction.json - Full extraction for all pages in chapter
  • page_6_pattern_analysis.json - (Optional) Pattern analysis for specific pages

Images (in output/chapter_XX/images/chapter_XX/):

  • page_XX_image_*.png - Embedded images from page
  • page_XX_images.json - Metadata for embedded images

Rich Extraction JSON Format

{
  "page_number": 16,
  "pdf_index": 15,
  "book_page": 17,
  "chapter": 2,
  "dimensions": {
    "width": 612,
    "height": 792
  },
  "text_spans": [
    {
      "text": "Rights in Real Estate",
      "font": "Arial-BoldMT",
      "size": 27.04,
      "bold": true,
      "italic": false,
      "bbox": {
        "x0": 72,
        "y0": 150,
        "x1": 400,
        "y1": 177
      },
      "color": 0,
      "sequence": 1
    }
  ],
  "analysis": {
    "font_sizes": {
      "27.04": 1,
      "11.04": 45
    },
    "font_styles": {
      "bold_27.04": 1,
      "regular_11.04": 45
    },
    "likely_headings": [
      {
        "text": "Rights in Real Estate",
        "level": 1,
        "confidence": 0.95
      }
    ],
    "likely_paragraphs": [
      {
        "text": "Real property consists of...",
        "type": "body_text"
      }
    ]
  },
  "extraction_timestamp": "2025-11-08T14:30:00Z",
  "extraction_tool": "rich_extractor.py v1.0"
}

Python Commands to Execute

Step 1: Establish Page Mapping

cd Calypso/tools
python3 read_page_footers.py \
  --start 15 \
  --end 28 \
  --pdf "../PREP-AL 4th Ed 9-26-25.pdf" \
  --output "../analysis/page_mapping.json"

Success indicators:

  • Command exits with code 0
  • Page mapping JSON created/updated
  • All pages in range have entries

Step 2: Extract Rich Data

cd Calypso/tools
python3 rich_extractor.py \
  --pdf "../PREP-AL 4th Ed 9-26-25.pdf" \
  --start 15 \
  --end 28 \
  --output "../analysis/chapter_02/rich_extraction.json"

Success indicators:

  • Command exits with code 0
  • JSON file created
  • File contains text_spans array
  • All pages in range represented

Step 3: Render to PNG

cd Calypso/tools
python3 -c "
import fitz
pdf = fitz.open('../PREP-AL 4th Ed 9-26-25.pdf')
for page_idx in range(15, 29):
    page = pdf[page_idx]
    pix = page.get_pixmap(matrix=fitz.Matrix(3, 3))  # 300% zoom for high-res
    pix.save(f'../output/chapter_02/page_artifacts/page_{page_idx:02d}/02_page_{page_idx}.png')
pdf.close()
"

Step 4: Extract Images (if present)

cd Calypso/tools
# For each page with images
python3 extract_images.py \
  --page 17 \
  --pdf "../PREP-AL 4th Ed 9-26-25.pdf" \
  --output "../output" \
  --mapping "../analysis/page_mapping.json"

Quality Checks

Before declaring extraction complete:

  1. File existence

    • [ ] 01_rich_extraction.json exists
    • [ ] 02_page_XX.png exists and is valid
    • [ ] page_mapping.json exists
  2. JSON validity

    • [ ] JSON files parse without errors
    • [ ] All required fields present
    • [ ] No null/undefined values in critical fields
  3. Data completeness

    • [ ] All pages in range have text_spans
    • [ ] Text content is not empty
    • [ ] Font sizes are reasonable (> 0)
    • [ ] Bounding boxes are within page dimensions
  4. Image quality

    • [ ] PNG files are readable
    • [ ] Image dimensions match PDF page size
    • [ ] No corrupted or blank images

Error Handling

If PDF file not found:

  • Exit with error message
  • Do not create partial artifacts

If page mapping fails:

  • Fall back to default indexing (PDF index = book page - 1)
  • Log warning
  • Continue extraction

If rich extraction produces no text:

  • Check if page is image-only
  • Mark in metadata: "page_type": "image_only"
  • Continue (ASCII preview will handle image OCR)

If PNG rendering fails:

  • Use fallback: save raw PDF page as PDF image
  • Log warning
  • Continue to next step

Persistence & Traceability

All artifacts include metadata:

  • Extraction timestamp
  • Tool version
  • Input parameters
  • Processing status

This enables:

  • Reproducibility (re-extract with same parameters)
  • Debugging (trace what data was extracted)
  • Auditing (track all changes to artifacts)
  • Caching (skip re-extraction if unchanged)

Success Criteria

✓ All required files created in correct directories ✓ Rich extraction JSON is valid and complete ✓ PNG image renders correctly ✓ Page mapping is accurate ✓ All data persisted and ready for next skill ✓ No extraction errors or warnings

Next Steps

Once extraction completes successfully:

  1. Skill 2 will create ASCII preview from extracted data
  2. Skill 3 will use extraction + PNG + ASCII for HTML generation
  3. All artifacts available for validation and debugging

Troubleshooting

PDF won't open: Verify file path, ensure PDF is not corrupted No text extracted: Page may be image-only (OCR needed) Wrong page numbers: Check page_mapping.json for accuracy PNG images are blank: Try increasing zoom factor (3x = 300 DPI)

Implementation Notes

  • This skill is fully deterministic - same inputs always produce same outputs
  • Python tools ensure data quality and consistency
  • All files saved to persistent storage for audit trail
  • No AI involved at this stage - pure data extraction
  • Ready to support later AI-based HTML generation with complete context