PDF Utils
Use this skill for local, scriptable PDF processing. It is a stable 1.x skill for OCR, arXiv reference mining, and repeatable PyMuPDF workflows. Prefer the built-in pdf tool for AI-style reading, summarization, question-answering, and semantic analysis of PDF content.
Choose the right tool
- - Use the built-in
pdf tool for summary, Q&A, extraction by meaning, or general document understanding. - Use
scripts/extract_refs.py when the PDF already has extractable text and you need arXiv IDs or batch downloads. - Use
scripts/ocr_pdf.py when the PDF is scanned/image-based and text extraction is poor or empty. - Use
scripts/pdf_ops.py for repeatable local PDF operations such as merge, split, and rendering a page to an image.
Core workflows
Extract arXiv IDs from a text PDF
Run:
CODEBLOCK0
If needed, download the referenced papers:
CODEBLOCK1
OCR a scanned PDF
Run OCR on all pages:
CODEBLOCK2
To OCR and immediately extract arXiv IDs from the OCR output:
CODEBLOCK3
Dependencies
Install these before using OCR features:
CODEBLOCK4
Read more only if needed
- - Read
references/usage.md for CLI examples, programmatic API notes, PDF ops usage, and known limits. - Read the scripts directly if you need to patch behavior or reuse helper functions.
Practical guidance
- - For very large PDFs, OCR in page ranges or batches instead of all at once.
- For handwritten or low-resolution scans, expect OCR quality to drop.
- If a PDF yields partial references, inspect the reference pages first instead of assuming extraction is complete.
- For merge/split/page rendering, use
scripts/pdf_ops.py first before writing one-off snippets.
PDF 工具
使用此技能进行本地、可脚本化的PDF处理。这是一个稳定的1.x版本技能,适用于OCR、arXiv参考文献挖掘以及可重复的PyMuPDF工作流程。对于AI风格的阅读、摘要、问答和PDF内容的语义分析,建议优先使用内置的pdf工具。
选择合适的工具
- - 使用内置的 pdf工具 进行摘要、问答、按语义提取或通用文档理解。
- 当PDF已有可提取文本且需要获取arXiv ID或批量下载时,使用 scripts/extractrefs.py。
- 当PDF为扫描件/基于图像且文本提取效果差或为空时,使用 scripts/ocrpdf.py。
- 对于可重复的本地PDF操作(如合并、拆分、将页面渲染为图像),使用 scripts/pdf_ops.py。
核心工作流程
从文本PDF中提取arXiv ID
运行:
bash
python3 scripts/extract_refs.py paper.pdf
如需下载引用的论文:
bash
python3 scripts/extract_refs.py paper.pdf --download --out ~/papers/
对扫描版PDF进行OCR
对所有页面执行OCR:
bash
python3 scripts/ocr_pdf.py paper.pdf --all
执行OCR并立即从OCR输出中提取arXiv ID:
bash
python3 scripts/ocr_pdf.py paper.pdf --all --extract-refs
依赖项
使用OCR功能前请安装以下依赖:
bash
brew install tesseract
brew install tesseract-lang
pip3 install pytesseract Pillow pymupdf --break-system-packages
仅在需要时进一步阅读
- - 阅读 references/usage.md 了解命令行示例、编程API说明、PDF操作用法及已知限制。
- 如需修改行为或复用辅助函数,可直接阅读脚本。
实用指导
- - 对于超大型PDF,建议按页面范围或分批进行OCR,而非一次性处理全部。
- 手写体或低分辨率扫描件的OCR质量可能下降。
- 若PDF仅提取到部分参考文献,请先检查参考文献页面,而非直接认定提取完成。
- 对于合并/拆分/页面渲染操作,请优先使用 scripts/pdf_ops.py,而非编写一次性代码片段。