ocr-document
Extract text from PDFs, images, and scanned documents. Uses pymupdf (local) or optional cloud OCR APIs.
来源信息
- 仓库
- fuyuxiang/echo-agent
- 最近来源活动
- 2026年8月24日 06:42
- 检测到的 SKILL.md 语言
- 英语
- 星标
- 1,059
- 分支
- 27
安装方式
默认使用会先检查来源的 Prompt;你也可以切换为直接命令,或下载本地副本。
检查来源文件
决定是否安装前,请先阅读 SKILL.md,以及 SkillsMP 当前展示的配套文件。
文件资源管理器
2 个文件正在显示 SKILL.md
SKILL.md
来源说明 · 只读预览- name
- ocr-document
- description
- Extract text from PDFs, images, and scanned documents. Uses pymupdf (local) or optional cloud OCR APIs.
- version
- 1.0.0
- metadata
- {"echo":{"tags":["OCR","PDF","Document","Extract","Text"]}}
# OCR & Document Processing
Extract text from PDFs, scanned images, and documents.
## PDF Text Extraction (PyMuPDF)
Best choice for text-based PDFs:
```bash
pip install pymupdf
```
```python
import pymupdf
doc = pymupdf.open("file.pdf")
for page in doc:
text = page.get_text()
print(text)
# All pages at once
full_text = "\n".join(page.get_text() for page in doc)
```
## PDF → Markdown (marker-pdf)
High-quality conversion preserving structure:
```bash
pip install marker-pdf
marker_single file.pdf output_dir/ --output_format markdown
```
## Image OCR
### Surya OCR (Modern ML-based, best for Chinese)
```bash
pip install surya-ocr
surya_ocr image.png --langs zh,en
```
### Pytesseract (Traditional, widely available)
```bash
# Install Tesseract engine first
brew install tesseract tesseract-lang # macOS
apt install tesseract-ocr tesseract-ocr-chi-sim # Linux
pip install pytesseract Pillow
```
```python
import pytesseract
from PIL import Image
text = pytesseract.image_to_string(
Image.open("scan.png"),
lang="chi_sim+eng"
)
```
## Script
```bash
python3 scripts/extract_document.py document.pdf
python3 scripts/extract_document.py scan.png
python3 scripts/extract_document.py report.pdf --output extracted.txt
```
Auto-detects format by extension: PDF → pymupdf, DOCX → python-docx, Image → pytesseract.
OCR language is controlled by system Tesseract config (e.g., `chi_sim+eng` default).
## Tips
- For scanned PDFs, extract images first then OCR each page
- Preprocessing (deskew, contrast) improves OCR accuracy
- Chinese OCR: surya-ocr > pytesseract for accuracy
在 GitHub 查看