ocrmypdf
OCRmyPDF adds an OCR text layer to scanned PDF files, allowing them to be searched
What it is and what it does
OCRmyPDF is a command-line tool that takes scanned PDFs or images and adds an invisible searchable text layer using Tesseract OCR, making the content copy-pasteable and indexable. It preserves the original image resolution, optionally deskews crooked pages, cleans images before OCR, and can convert output to PDF/A format for long-term archival. The tool validates both input and output, distributes work across available CPU cores, and supports over 100 languages through Tesseract's language packs.
The package wraps Tesseract OCR and Ghostscript into a Python interface with 13 runtime dependencies including pikepdf for PDF manipulation, pillow for image handling, pydantic for configuration, and rich for CLI output. It runs on Linux, macOS, Windows, and FreeBSD. The tool is designed for batch processing and scales to handle files with thousands of pages; it keeps processed data private and does not require network access.
Use it for:
- Digitize paper documents or scanned PDFs to make them searchable and copy-pasteable for archival or document management systems.
- Batch convert image files (JPG, PNG) to single-page searchable PDFs for integration into document workflows.
- Prepare scanned documents for long-term storage by converting to PDF/A format with embedded OCR text.
- Straighten and clean crooked or low-quality scans before OCR to improve recognition accuracy.
- Process multilingual documents by specifying multiple language codes (e.g., eng+fra) to recognize mixed-language content.
- Optimize PDF file sizes while adding OCR, reducing storage overhead for large document collections.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
OCRmyPDF adds searchable text layers to scanned PDF files using Tesseract OCR, enabling them to be searched and copy-pasted while optionally deskewing, cleaning, and converting to PDF/A format.
Yes. OCRmyPDF is actively maintained, widely used (top 5000 PyPI packages, 1.17M monthly downloads), has no known vulnerabilities, and solves a specific, well-defined problem. Low install friction and copyleft licensing pose no barrier for most users. The main prerequisite—external system binaries (Tesseract, Ghostscript)—is clearly documented and available across major platforms. Install it if you need to make scanned PDFs searchable.
Install
ocrmypdf on PyPI
pip
pip install ocrmypdfuv
uv add ocrmypdfpoetry
poetry add ocrmypdfInstalling ocrmypdf
Before you install
Low friction: pure Python wheel with 13 runtime dependencies. Active maintenance—last release 9 days ago, repository at 34446 stars with recent commits. Requires external system binaries (Tesseract OCR and Ghostscript) to function.
License in practice
MPL-2.0 (copyleft): you may use and modify the package freely, but any modifications you distribute must be released under the same license. Suitable for most commercial and open-source projects, though distribution of modified versions carries obligations.
Quickstart
pip install ocrmypdf
ocrmypdf -l eng input_scanned.pdf output_searchable.pdf
Requires Tesseract OCR and Ghostscript to be installed and available on PATH; Python >=3.11 required.
Verify before relying
- Performance characteristics on large multi-page documents (fact sheet mentions thousands of pages but provides no benchmarks).
- Actual file size reduction from image optimization (description claims files often smaller than input but no metrics given).
- Accuracy of OCR output across the 100+ supported languages (language support confirmed but quality variance unknown).
Package facts
| License | MPL-2.0 (copyleft) |
| Python support | supports the current Python release (>=3.11) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 13 — fpdf2, img2pdf, packaging, pdfminer-six, pi-heif, pikepdf, pillow, pluggy, pydantic, pypdfium2, rich, typing-extensions, uharfbuzz |
| Maintenance | actively maintained — 9 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,169,727/month — #4,272 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: ocrmypdf-17.10.0-py3-none-any.whl
Keywords: OCR, PDF, PDF/A, optical character recognition, scanning
Tags
More Linguistic packages
Detects and normalizes text encoding from…
permissive · top 100 on PyPI
tiktokentiktoken is a fast BPE tokenizer that converts…
permissive · top 1,000 on PyPI
chardetDetects character encoding and language in byte…
permissive · top 1,000 on PyPI
text-unidecodeConverts Unicode text to ASCII by…
copyleft · top 1,000 on PyPI
larkLark is a parsing library that builds abstract…
permissive · top 1,000 on PyPI
tree-sitterPython bindings to the tree-sitter parsing…
permissive · top 1,000 on PyPI
unstructured.pytesseractPython wrapper for Google's Tesseract OCR…
permissive · top 15,000 on PyPI
tesserocrtesserocr wraps Tesseract's C++ OCR engine via…
permissive · top 15,000 on PyPI
pikepdfpikepdf reads, writes, repairs, and transforms…
copyleft · top 5,000 on PyPI
marker-pdfMarker converts PDFs, images, and other…
permissive · top 15,000 on PyPI
pdfservices-sdkClient library for Adobe PDF Services API,…
permissive · top 15,000 on PyPI
pytesseractPytesseract wraps Google's Tesseract-OCR engine…
permissive · top 1,000 on PyPI
mineruConverts PDF, DOCX, PPTX, XLSX, images, and web…
unclear · top 15,000 on PyPI
paddleocrPaddleOCR extracts text, tables, and structured…
permissive · top 5,000 on PyPI
pyocrPyOCR wraps multiple OCR engines (Tesseract,…
copyleft · top 15,000 on PyPI
img2tableIdentifies and extracts tables from images and…
permissive · top 15,000 on PyPI