extracting-pdf-text by letta-ai/skills
npx skills add https://github.com/letta-ai/skills --skill extracting-pdf-text此技能提供了从 PDF 中提取文本的工具和指南,提取格式适合语言模型使用。
| PDF 类型 | 最佳方法 | 脚本 |
|---|---|---|
| 纯文本 PDF | PyMuPDF | scripts/extract_pymupdf.py |
| 包含表格的 PDF | pdfplumber | scripts/extract_pdfplumber.py |
| 扫描/图像 PDF(本地) | pytesseract | scripts/extract_with_ocr.py |
| 复杂布局,最高精度 | Mistral OCR API | scripts/extract_mistral_ocr.py |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 端到端 RAG 流程 | marker-pdf | pip install marker-pdf |
最佳适用场景:文本密集的 PDF、速度要求高的工作流、基本结构保留。
uv run scripts/extract_pymupdf.py input.pdf output.md
该脚本输出保留标题和段落的 Markdown。对于为 LLM 优化的输出,它使用 pymupdf4llm 来为 RAG 系统格式化文本。
最佳适用场景:包含表格的 PDF、财务文档、结构化数据。
uv run scripts/extract_pdfplumber.py input.pdf output.md
表格被转换为 Markdown 格式。注意:pdfplumber 在机器生成的 PDF 上效果最好,而非扫描文档。
最佳适用场景:无法访问 API 时的扫描 PDF。
uv run scripts/extract_with_ocr.py input.pdf output.txt
需要:pytesseract、pdf2image 以及已安装的 Tesseract(在 macOS 上使用 brew install tesseract)。
最佳适用场景:复杂布局、扫描文档、最高精度、多语言内容、数学公式。
定价:约每美元 1000 页(非常经济高效)
export MISTRAL_API_KEY="your-key"
uv run scripts/extract_mistral_ocr.py input.pdf output.md
特性:
有关详细的 API 选项和其他服务,请参阅 references/api-services.md。
对于 LLM 使用,推荐 Markdown:
有关本地工具的详细比较,请参阅 references/local-tools.md。
每周安装量
205
代码仓库
GitHub 星标数
74
首次出现
2026 年 1 月 24 日
安全审计
安装于
opencode180
codex178
gemini-cli174
github-copilot167
cursor165
kimi-cli157
This skill provides tools and guidance for extracting text from PDFs in formats suitable for language model consumption.
| PDF Type | Best Approach | Script |
|---|---|---|
| Simple text PDF | PyMuPDF | scripts/extract_pymupdf.py |
| PDF with tables | pdfplumber | scripts/extract_pdfplumber.py |
| Scanned/image PDF (local) | pytesseract | scripts/extract_with_ocr.py |
| Complex layout, highest accuracy | Mistral OCR API | scripts/extract_mistral_ocr.py |
| End-to-end RAG pipeline | marker-pdf | pip install marker-pdf |
Best for: Text-heavy PDFs, speed-critical workflows, basic structure preservation.
uv run scripts/extract_pymupdf.py input.pdf output.md
The script outputs markdown with preserved headings and paragraphs. For LLM-optimized output, it uses pymupdf4llm which formats text for RAG systems.
Best for: PDFs with tables, financial documents, structured data.
uv run scripts/extract_pdfplumber.py input.pdf output.md
Tables are converted to markdown format. Note: pdfplumber works best on machine-generated PDFs, not scanned documents.
Best for: Scanned PDFs when API access is unavailable.
uv run scripts/extract_with_ocr.py input.pdf output.txt
Requires: pytesseract, pdf2image, and Tesseract installed (brew install tesseract on macOS).
Best for: Complex layouts, scanned documents, highest accuracy, multilingual content, math formulas.
Pricing : ~1000 pages per dollar (very cost-effective)
export MISTRAL_API_KEY="your-key"
uv run scripts/extract_mistral_ocr.py input.pdf output.md
Features:
For detailed API options and other services, see references/api-services.md.
For LLM consumption, markdown is preferred:
For detailed comparisons of local tools, see references/local-tools.md.
Weekly Installs
205
Repository
GitHub Stars
74
First Seen
Jan 24, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
opencode180
codex178
gemini-cli174
github-copilot167
cursor165
kimi-cli157
AI Elements:基于shadcn/ui的AI原生应用组件库,快速构建对话界面
62,200 周安装