
Extracting with OCR
FreeEfficiently extract text from image-based documents.
Free · Opens the source repo
What Extracting with OCR does
Extracting with OCR is a command-line skill designed to facilitate the extraction of text from image-based documents, such as scanned PDFs, photographs, and screenshots. This tool is particularly useful for developers and designers who frequently work with documents that lack an embedded text layer. It employs Optical Character Recognition (OCR) to convert images of text into machine-readable text, making it easier to manipulate and analyze data from various sources.
The skill supports multiple OCR backends, including Tesseract, PaddleOCR, and Candle VLM, allowing users to choose the most appropriate engine for their specific needs. Tesseract, the default backend, is well-suited for general-purpose OCR tasks and supports over 100 languages. Users can easily switch to other backends if they encounter accuracy issues or need to handle specific scripts, such as Asian characters. The skill also includes performance tuning options, enabling users to optimize extraction speed and accuracy based on their requirements.
For users who often deal with mixed content types, such as documents that combine scanned and digital text, the skill provides a --force-ocr option. This feature ensures that every page is processed with OCR, even if a text layer is present, which can be particularly beneficial when the text layer is unreliable. Additionally, the skill allows for batch processing, making it efficient for users who need to extract text from multiple files at once.
Overall, Extracting with OCR is an essential tool for anyone needing to convert image-based documents into editable text, streamlining workflows and enhancing productivity in document management tasks.
When to use it
Use this skill when you need to extract text from scanned PDFs, photographs, or images without embedded text.
When not to use it
Avoid this skill if you are only working with documents that already have a reliable text layer, as it may be unnecessary.
What you can build with it
Extracting text from scanned documents
Use this skill to convert scanned documents into editable text, facilitating easier data manipulation.
Batch processing of images
Quickly extract text from multiple image files in one command, saving time on manual processing.
Handling mixed content types
Effectively extract text from documents that contain both scanned images and digital text.
How to install Extracting with OCR
View source1. Install with the skills CLI
npx skills add xberg-io/xberg/extracting-with-ocr --agent claude-code2. Or install it manually
Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.
Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs
Inside SKILL.md
Written by xberg-ioExtracting 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 (extract embedded text only or fail).--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 bogus zero-width text layer. Re-run with--force-ocr=true. - OCR on a rotated page — add
--ocr-auto-rotate=trueor pre-rotate. - Garbled CJK output — ensure the right language pack is installed and
passed via
--ocr-language; considerpaddle-ocrfor Chinese/Japanese.
See references/cli-reference.md and references/configuration.md in the
sibling xberg skill for the full flag and config schema.
Frequently asked questions about Extracting with OCR
Similar skills
PaddleOCR Text Recognition
Extract text from images and PDFs with high accuracy.
Defuddle
Extract and clean web pages as Markdown with consent.
PDFtk Server
Command-line tool for comprehensive PDF manipulation.
Latchshot Page Capture
Capture public web pages as images or PDFs easily.
Convert Word to Markdown
Effortlessly convert .docx files to Markdown format.
Convert PDF to Markdown
Transform PDF documents into Markdown for easier analysis.
