{"data":{"slug":"github-xberg-io-xberg-plugin-cursor-plugin-skills-xberg-extracting-with-ocr-6b203b831dc6","title":"Extract Text from Scanned Documents Using OCR","summary":"Extract text from scanned PDFs, photographed pages, or images with no embedded text layer using OCR. Supports multiple backends, languages, and performance tuning.","url":"https:\/\/skillshunter.net\/skills\/github-xberg-io-xberg-plugin-cursor-plugin-skills-xberg-extracting-with-ocr-6b203b831dc6","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-xberg-io-xberg-plugin-cursor-plugin-skills-xberg-extracting-with-ocr-6b203b831dc6","markdown_url":"https:\/\/skillshunter.net\/skills\/github-xberg-io-xberg-plugin-cursor-plugin-skills-xberg-extracting-with-ocr-6b203b831dc6.md","download_url":"https:\/\/skillshunter.net\/skills\/github-xberg-io-xberg-plugin-cursor-plugin-skills-xberg-extracting-with-ocr-6b203b831dc6\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"The tool requires a supported OCR backend (e.g., Tesseract, PaddleOCR) and may need language packs installed at the OS level for specific languages.","instructions":"---\ndescription: 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.\nname: xberg-extracting-with-ocr\n---\n\n<!--\nAI-RULEZ :: GENERATED FILE \u2014 DO NOT EDIT\nContent-Hash: blake3:b1718303d659167ff376b4e1d4baf546d3e74f8f0804698a3486c0a1d2e6c913\nSource-Hash: blake3:ab2bcd453f9c2ded67752f6a9800186d42b6921f4be16f6ab3a773254a9fba00\nSchema-Version: v1\n-->\n\n# Extracting with OCR\n\nUse this when a document is image-based: scanned PDFs, photographed pages,\nscreenshots, JPEG\/PNG\/TIFF with text. Xberg auto-OCRs raster images and\nauto-detects PDFs that lack a text layer. Force it on when extraction\nreturned empty\/garbled text from a PDF that \"looks\" textual.\n\n## When to force OCR\n\n- Extraction returned an empty `content` field, but the file opens visually.\n- The PDF text layer is junk (copy-paste from a viewer produces gibberish).\n- You want consistent output across mixed scanned + digital PDFs.\n\n```bash\nxberg extract scan.pdf --force-ocr=true\nxberg extract scan.pdf --ocr=true --ocr-language eng\n```\n\nIf a page has an unreliable text layer, `--force-ocr=true` re-rasterizes\nand runs OCR on every page.\n\n## Backends\n\nTesseract is the default and ships with the CLI \u2014 no extra install. Other\nbackends are opt-in:\n\n| Backend       | Flag                                  | Install                                          | Notes                                                          |\n| ------------- | ------------------------------------- | ------------------------------------------------ | -------------------------------------------------------------- |\n| Tesseract     | `--ocr-backend tesseract` (default)   | bundled                                          | Best general-purpose, 100+ languages via tessdata.             |\n| PaddleOCR     | `--ocr-backend paddle-ocr`            | bundled (ONNX Runtime)                           | Strong on Asian scripts. Not available on WASM or Windows.     |\n| 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`). |\n| 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. |\n\nPick Tesseract first. Switch only when accuracy is unacceptable.\n\n## Language packs\n\nTesseract uses ISO 639-2 codes. Default is `eng`. Combine with `+`:\n\n```bash\nxberg extract menu.jpg --ocr=true --ocr-language \"eng+deu\"\nxberg extract bilingual.pdf --ocr-language \"eng+jpn\"\nxberg extract any.pdf --ocr-language all   # all installed packs\n```\n\nInstall missing packs at the OS level:\n\n```bash\n# macOS\nbrew install tesseract-lang\n\n# Debian\/Ubuntu\nsudo apt install tesseract-ocr-deu tesseract-ocr-jpn tesseract-ocr-fra\n\n# Specific lang only\nsudo apt install tesseract-ocr-<iso639-2>\n```\n\nXberg fails fast with a helpful error if you request a language pack\nthat is not installed. Read the error \u2014 it names the missing file.\n\n## Useful flags\n\n- `--ocr=true` \u2014 enable OCR (auto-enabled for images and scanned PDFs).\n- `--force-ocr=true` \u2014 OCR every page even if a text layer exists.\n- `--disable-ocr=true` \u2014 never OCR; use embedded text where available. Images and image-only pages can return metadata with no recognized text.\n- `--ocr-language <lang>` \u2014 single code or `+`-joined list, or `all`.\n- `--ocr-backend <tesseract|paddle-ocr|vlm|candle-trocr|candle-paddleocr-vl|candle-glm-ocr|candle-deepseek-ocr>` \u2014 pick backend.\n- `--ocr-auto-rotate=true` \u2014 pre-rotate via the auto-rotate model.\n- `--acceleration <cpu|coreml|cuda|tensorrt|auto>` \u2014 ONNX accelerator for\n  paddle-ocr \/ auto-rotate \/ layout models.\n\n## Performance tips\n\n- Cache is on by default. Repeated extraction of the same file + config is\n  instant. Do not pass `--no-cache=true` unless you have a reason.\n- For batch OCR, use `xberg batch *.pdf --ocr=true` \u2014 internal worker\n  pool parallelizes across CPU cores. Cap with `--max-concurrent N` if\n  memory is tight.\n- Raise `--target-dpi` (default 300) only for low-resolution scans. Higher\n  DPI is slower; 200 is usually enough for printed text.\n- Enable `--ocr-auto-rotate=true` only when pages may be rotated; the\n  classifier adds latency.\n- On Apple Silicon, `--acceleration coreml` typically beats CPU for\n  paddle-ocr and layout detection.\n\n## Config file alternative\n\nLong flag chains belong in `xberg.toml` \u2014 auto-discovered from cwd\nupward.\n\n```toml\nforce_ocr = true\noutput_format = \"markdown\"\n\n[ocr]\nbackend = \"tesseract\"\nlanguage = \"eng+deu\"\nauto_rotate = true\n```\n\nThen just run:\n\n```bash\nxberg extract document.pdf\n```\n\n## Common failure modes\n\n- **\"missing tessdata\"** \u2014 install the language pack at OS level (see above).\n- **Empty content on a scanned PDF without `--force-ocr`** \u2014 the file has a\n  bogus zero-width text layer. Re-run with `--force-ocr=true`.\n- **OCR on a rotated page** \u2014 add `--ocr-auto-rotate=true` or pre-rotate.\n- **Garbled CJK output** \u2014 ensure the right language pack is installed and\n  passed via `--ocr-language`; consider `paddle-ocr` for Chinese\/Japanese.\n\nSee `references\/cli-reference.md` and `references\/configuration.md` for the full flag and config schema.\n","use_cases":["Extract text from a scanned PDF with no text layer","OCR a photographed page of a document","Extract text from a mixed scanned and digital PDF"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/xberg-io\/xberg\/blob\/ffbf7971796a126fc52f6bb8fb40418772071f61\/plugin\/.cursor-plugin\/skills\/xberg-extracting-with-ocr\/SKILL.md","source_commit":"ffbf7971796a126fc52f6bb8fb40418772071f61","license":null,"version":null,"listing_approved_at":"2026-11-16","created_at":"2026-11-15T14:41:50.000000Z","updated_at":"2026-11-16T05:17:13.000000Z","seo_title":"Extract Text from Scanned PDFs with OCR","seo_description":"Use OCR to extract text from scanned PDFs, images, and photographed pages. Supports Tesseract, PaddleOCR, and multimodal LLMs for accurate results.","seo_keywords":["OCR scanned PDF","extract text from image","OCR PDF without text layer","OCR scanned document","image to text OCR"]}}