A toolset for parsing PDF content, including text extraction, table data retrieval, and rendering pages as images.

Install

mkdir -p .claude/skills/pdf-process && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/15023" && unzip -o skill.zip -d .claude/skills/pdf-process && rm skill.zip

Installs to .claude/skills/pdf-process

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

从 PDF 文件中提取文字、表格、图像,并解析内容。适用于:读取PDF试题、分析PDF文档、提取PDF中的表格数据、将PDF页面转为图片。关键词:pdf、读取、提取、试题、表格、图像。
92 charsno explicit “when” trigger
Beginner

Key capabilities

  • Extract text content from PDF files
  • Extract tabular data from PDF files
  • Render PDF pages as images
  • Process text-based PDFs
  • Handle graphic-rendered tables by converting to images

How it works

This skill uses the `pymupdf` library to open PDF documents and provides methods to extract text, identify and extract tables, or render individual pages as images. It offers a decision flow to determine the best extraction method based on the PDF's content type.

Inputs & outputs

You give it
A PDF file path
You get back
Extracted text, tabular data, or PNG image files of PDF pages

When to use pdf-process

  • Extract table data from PDF reports
  • Parse text from PDF documents
  • Convert PDF pages to images

About this skill

PDF 处理技能

适用场景

  • 读取 PDF 文件中的文字内容(如试题、文档、报告)
  • 提取 PDF 中的表格数据
  • 将 PDF 页面渲染为图片(用于查看图表、手写内容等)
  • 解析图片内容后再进行文字分析

依赖库

使用 pymupdf(包名为 pymupdf,导入名为 pymupdffitz)。

环境准备(按优先级执行,满足即止)

第一步:检查当前环境是否已有 pymupdf

python -c "import pymupdf; print(pymupdf.__version__)"
  • 若输出版本号 → 直接使用,无需任何安装操作。
  • 若报 ModuleNotFoundError → 进入第二步。

第二步:尝试其他已有 Python 环境

Windows 下可能存在多个 Python,先列出:

where.exe python

逐个检查是否已有 pymupdf:

<完整路径>\python.exe -c "import pymupdf; print(pymupdf.__version__)"

若某个环境已有 → 后续脚本改用该完整路径调用,无需安装。

第三步:仅在当前项目内安装(不污染全局环境)

若所有已有环境均无 pymupdf,在项目目录内创建虚拟环境安装:

# 在项目根目录创建 .venv(只影响此目录)
python -m venv .venv
.venv\Scripts\Activate.ps1
pip install pymupdf

安装后,后续所有 Python 操作均在 .venv 内执行。用完后 deactivate 退出。

原则:优先复用已有环境,确实缺包时才安装,且安装范围限于项目 .venv,不执行全局 pip install


方法一:提取文字

import pymupdf

doc = pymupdf.open(r"path\to\file.pdf")
for i, page in enumerate(doc):
    print(f"=== 第{i+1}页 ===")
    print(page.get_text())
  • page.get_text() 返回该页所有可选中的文字
  • 适用于文字型 PDF(非扫描版)

方法二:提取表格

import pymupdf

doc = pymupdf.open(r"path\to\file.pdf")
for i, page in enumerate(doc):
    tabs = page.find_tables()
    for j, tab in enumerate(tabs.tables):
        print(f"第{i+1}页 表格{j+1}:")
        for row in tab.extract():
            print(row)
  • 若返回 0 个表格,说明 PDF 中表格是图形渲染的,需改用方法三(渲染为图片)查看

方法三:渲染为图片

当 PDF 包含图形化表格、图表或扫描内容时,将页面渲染为图片后使用 view_image 工具查看:

import pymupdf

doc = pymupdf.open(r"path\to\file.pdf")
for i, page in enumerate(doc):
    mat = pymupdf.Matrix(2, 2)   # 2x 缩放,提高清晰度
    pix = page.get_pixmap(matrix=mat)
    out_path = rf"path\to\output\page_{i+1}.png"
    pix.save(out_path)
    print(f"Saved page {i+1} → {out_path}")

保存后用 view_image 工具查看图片,再手动录入图片中的表格数据。


决策流程

读取 PDF
  ├─ 先用方法一提取文字 → 检查内容是否完整
  │     └─ 完整 → 直接使用文字内容
  │     └─ 缺表格/图表 → 继续
  ├─ 用方法二提取表格 → 检查是否有表格
  │     └─ 有表格 → 使用表格数据
  │     └─ 返回0个表格(图形渲染)→ 继续
  └─ 用方法三渲染为图片 → view_image 查看 → 手动录入

实战示例(2024上半年案例分析真题)

# 1. 提取文字(获取题目文本)
import pymupdf
doc = pymupdf.open(r'd:\ruankao\resource\近五年真题\2024上_案例分析_批一.pdf')
for i, page in enumerate(doc):
    print(f'=== 第{i+1}页 ===')
    print(page.get_text())

# 2. 表格提取失败(返回0个),改为渲染图片
for i, page in enumerate(doc):
    mat = pymupdf.Matrix(2, 2)
    pix = page.get_pixmap(matrix=mat)
    pix.save(rf'd:\ruankao\resource\近五年真题\page_{i+1}.png')

# 3. 使用 view_image 查看 page_3.png、page_4.png 获取表格数据

结果:文字内容通过方法一获取,图形化表格通过渲染图片 + view_image 工具读取。

When not to use it

  • When the primary goal is not PDF content extraction or rendering
  • When only needing to view PDF files without processing their content

Prerequisites

pymupdf

Limitations

  • Table extraction may fail for graphic-rendered tables
  • Requires manual data entry for graphic-rendered tables converted to images
  • Primarily designed for content extraction, not PDF editing

How it compares

This skill provides a structured approach to extracting various content types from PDFs, including a decision flow for handling graphic-rendered tables, unlike a generic PDF viewer.

Compared to similar skills

pdf-process side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
pdf-process (this skill)03moNo flagsBeginner
pdf04moReviewIntermediate
pdf-processing379moReviewIntermediate
pdf-processing-pro1710moReviewIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

You might also like

pdf

sam-cogan

Read, extract, create, merge, split, rotate, watermark, encrypt, OCR, or fill forms in PDF files. Triggers: any mention of \".pdf\", \"PDF\", or requests to extract text/tables from PDFs, combine/merge PDFs, split pages, create new PDFs, fill PDF forms, add watermarks, encrypt/decrypt, extract image

00

pdf-processing

Ming-Kai-LC

Comprehensive PDF processing techniques for handling large files that exceed Claude Code's reading limits, including chunking strategies, text/table extraction, and OCR for scanned documents. Use when working with PDFs larger than 10-15MB or more than 30-50 pages.

37171

pdf-processing-pro

davila7

Production-ready PDF processing with forms, tables, OCR, validation, and batch operations. Use when working with complex PDF workflows in production environments, processing large volumes of PDFs, or requiring robust error handling and validation.

17110

pdf-processor

lofcz

Extracts text and tables from PDF files, fills forms, and merges documents. Use when working with PDF files or when the user mentions PDFs, forms, or document extraction.

12

quant-analyst

zenobi-us

Expert quantitative analyst specializing in financial modeling, algorithmic trading, and risk analytics. Masters statistical methods, derivatives pricing, and high-frequency trading with focus on mathematical rigor, performance optimization, and profitable strategy development.

103355

stock-analyzer

FrancyJGLisboa

Provides comprehensive technical analysis for stocks and ETFs using RSI, MACD, Bollinger Bands, and other indicators. Activates when user requests stock analysis, technical indicators, trading signals, or market data for specific ticker symbols.

71214

Search skills

Search the agent skills registry