xberg-extracting-with-ocr
Skill này làm gì
Skill này chỉ cách lấy văn bản từ tài liệu dạng hình ảnh bằng OCR. Nó dành cho người có giấy tờ quét, trang chụp hoặc ảnh chụp màn hình.
Khi nào nên dùng
- ✓Khi bạn có một PDF quét hoặc ảnh chụp một trang và cần lấy văn bản từ đó.
- ✓Khi một PDF ra kết quả rỗng hoặc bị lỗi chữ nhưng nhìn trên màn hình vẫn đọc được.
- ✓Khi bạn cần văn bản từ một tài liệu bằng ngôn ngữ khác và phải đặt ngôn ngữ đó.
Liên kết skill
https://github.com/xberg-io/xberg/blob/main/plugin/.ai-rulez/skills/xberg-extracting-with-ocr/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Lấy văn bản từ file PDF hợp đồng quét này, được viết bằng tiếng Tây Ban Nha.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Agent bật OCR, hoặc ép dùng OCR cho mọi trang khi lớp văn bản kém chất lượng. Mặc định nó dùng công cụ Tesseract có sẵn và có thể đặt ngôn ngữ dùng để nhận dạng.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
Extracting with OCR
Use this when a document is image-based: scanned PDFs, photographed pages, screenshots, JPEG/PNG/TIFF with text. Xberg auto-OCRs raster images and auto-detects PDFs that lack a text layer. Force it on when extraction returned empty/garbled text from a PDF that "looks" textual.
When to force OCR
- Extraction returned an empty
contentfield, but the file opens visually. - The PDF text layer is junk (copy-paste from a viewer produces gibberish).
- You want consistent output across mixed scanned + digital PDFs.
xberg extract scan.pdf --force-ocr=true
xberg extract scan.pdf --ocr=true --ocr-language eng
If a page has an unreliable text layer, --force-ocr=true re-rasterizes
and runs OCR on every page.
Backends
Tesseract is the default and ships with the CLI — no extra install. Other backends are opt-in:
| Backend | Flag | Install | Notes |
|---|---|---|---|
| Tesseract | --ocr-backend tesseract (default) |
bundled | Best general-purpose, 100+ languages via tessdata. |
| PaddleOCR | --ocr-backend paddle-ocr |
bundled (ONNX Runtime) | Strong on Asian scripts. Not available on WASM or Windows. |
| Candle VLM | --ocr-backend candle-trocr (and other candle-*) |
bundled (Candle) | Local vision OCR models (candle-trocr, candle-paddleocr-vl, candle-glm-ocr, candle-deepseek-ocr). |
| VLM (hosted) | --ocr-backend vlm + --vlm-model |
liter-llm provider (--vlm-api-key) |
Multimodal LLM via liter-llm. Use when OCR fails on dense or handwritten layouts. |
Pick Tesseract first. Switch only when accuracy is unacceptable.
Language packs
Tesseract uses ISO 639-2 codes. Default is eng. Combine with +:
xberg extract menu.jpg --ocr=true --ocr-language "eng+deu"
xberg extract bilingual.pdf --ocr-language "eng+jpn"
xberg extract any.pdf --ocr-language all # all installed packs
Install missing packs at the OS level:
# macOS
brew install tesseract-lang
# Debian/Ubuntu
sudo apt install tesseract-ocr-deu tesseract-ocr-jpn tesseract-ocr-fra
# Specific lang only
sudo apt install tesseract-ocr-<iso639-2>
Xberg fails fast with a helpful error if you request a language pack that is not installed. Read the error — it names the missing file.
Useful flags
--ocr=true— enable OCR (auto-enabled for images and scanned PDFs).--force-ocr=true— OCR every page even if a text layer exists.--disable-ocr=true— never OCR; use embedded text where available. Images and image-only pages can return metadata with no recognized text.--ocr-language <lang>— single code or+-joined list, orall.--ocr-backend <tesseract|paddle-ocr|vlm|candle-trocr|candle-paddleocr-vl|candle-glm-ocr|candle-deepseek-ocr>— pick backend.--ocr-auto-rotate=true— pre-rotate via the auto-rotate model.--acceleration <cpu|coreml|cuda|tensorrt|auto>— ONNX accelerator for paddle-ocr / auto-rotate / layout models.
Performance tips
- Cache is on by default. Repeated extraction of the same file + config is
instant. Do not pass
--no-cache=trueunless you have a reason. - For batch OCR, use
xberg batch *.pdf --ocr=true— internal worker pool parallelizes across CPU cores. Cap with--max-concurrent Nif memory is tight. - Raise
--target-dpi(default 300) only for low-resolution scans. Higher DPI is slower; 200 is usually enough for printed text. - Enable
--ocr-auto-rotate=trueonly when pages may be rotated; the classifier adds latency. - On Apple Silicon,
--acceleration coremltypically beats CPU for paddle-ocr and layout detection.
Config file alternative
Long flag chains belong in xberg.toml — auto-discovered from cwd
upward.
force_ocr = true
output_format = "markdown"
[ocr]
backend = "tesseract"
language = "eng+deu"
auto_rotate = true
Then just run:
xberg extract document.pdf
Common failure modes
- "missing tessdata" — install the language pack at OS level (see above).
- Empty content on a scanned PDF without
--force-ocr— the file has a bog
Câu hỏi thường gặp
OCR có cần phần mềm bổ sung không?
Tesseract đi kèm công cụ theo mặc định, nên việc dùng cơ bản không cần cài thêm. Các công cụ OCR khác là tùy chọn.
Ép OCR là gì?
Nghĩa là mọi trang đều được đọc bằng OCR, ngay cả khi trang đã có một ít văn bản nhúng.
Những ngôn ngữ nào được hỗ trợ?
Tesseract hỗ trợ hơn 100 ngôn ngữ thông qua các file dữ liệu ngôn ngữ.
Chi tiết
Mô tả gốc của tác giả
Use when extracting text from scanned PDFs, photographed pages, or images that have no embedded text layer. Covers OCR backends, language packs, force-OCR, and performance tuning.
repo: xberg-io/xberg
Độ phổ biến
- Sao GitHub
- 9.5k
- Vị trí xếp hạng
- #12272
- Giấy phép
- MIT
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
xberg-batch-extraction
9.5kGiúp agent của bạn xử lý nhiều tài liệu một lượt với Xberg, dùng chung tùy chọn, giới hạn việc song song và không để một file lỗi làm dừng cả lượt.
xberg-chunking
9.5kGiúp agent của bạn chia văn bản dài thành các đoạn nhỏ cho prompt AI hoặc chỉ mục tìm kiếm, với kích thước đặt sẵn và chồng lấp tùy chọn.
xberg-extracting-keywords
9.5kGiúp agent của bạn lấy các từ khóa chính hoặc cụm từ khóa từ tài liệu và nhận diện ngôn ngữ của tài liệu, bằng các cài đặt từ khóa của Xberg.
xberg-extracting-tables
9.5kGiúp agent của bạn lấy bảng từ PDF, bảng tính và hình ảnh, giữ nguyên hàng và cột dưới dạng markdown hoặc dữ liệu có cấu trúc.
Skill tương tự
feishu-doc
394kGiúp agent của bạn đọc, tạo và sửa tài liệu đám mây Feishu, gồm văn bản, hình ảnh và bảng, bằng công cụ tài liệu.
feishu-drive
394kCho phép agent của bạn duyệt, sắp xếp và bình luận các file trong một thư mục đám mây Feishu đã được chia sẻ với bot.
feishu-perm
394kGiúp agent của bạn kiểm tra và thay đổi ai có quyền truy cập một file Feishu, chọn quyền nhỏ nhất đáp ứng yêu cầu của bạn.