xberg-extracting-with-ocr
What it does
This skill shows how to get text out of image-based documents using OCR. It is for people with scanned paperwork, photographed pages or screenshots.
When to use it
- βWhen you have a scanned PDF or a photo of a page and need the text.
- βWhen a PDF comes out empty or garbled but looks readable on screen.
- βWhen you need text from a document in another language and must set the language.
Skill link
https://github.com/xberg-io/xberg/blob/main/plugin/.ai-rulez/skills/xberg-extracting-with-ocr/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βPull the text out of this scanned contract PDF, which is written in Spanish.β
5 new skills a week. 1 minute to read.
How it works
The agent turns on OCR, or forces it for every page when the text layer is poor. It uses the built-in Tesseract engine by default and can set the language used for recognition.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
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
FAQ
Does OCR need extra software?
Tesseract comes with the tool by default, so basic use needs no extra install. Other OCR engines are optional.
What is force OCR?
It means every page is read with OCR, even if the page has some embedded text.
Which languages are supported?
Tesseract supports more than 100 languages through language data files.
Details
Original description by the author
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
Popularity
- GitHub stars
- 9.5k
- Ranking position
- #12272
- License
- MIT
- Updated
- 11/2/2026
Comments
- β¦
More skills from this repository
xberg-batch-extraction
9.5kHelps your agent process many documents at once with Xberg, sharing one set of options, limiting parallel work and keeping failed files from stopping the run.
xberg-chunking
9.5kHelps your agent split long document text into smaller pieces for AI prompts or search indexes, with set sizes and optional overlap.
xberg-extracting-keywords
9.5kHelps your agent pull the main keywords or key phrases from a document and detect its language, using Xberg's keyword settings.
xberg-extracting-tables
9.5kHelps your agent pull tables out of PDFs, spreadsheets and images, keeping rows and columns intact as markdown or structured data.
Similar skills
feishu-doc
394kHelps your agent read, create, and edit Feishu cloud documents, including text, images, and tables, using the document tool.
feishu-drive
394kLets your agent browse, organize, and comment on files in a Feishu cloud folder that has been shared with the bot.
feishu-perm
394kHelps your agent check and change who can access a Feishu file, choosing the smallest permission that meets your request.