ocrmypdf /OCRmyPDF

OCRmyPDF adds an OCR text layer to scanned PDF files, allowing them to be searched

★ 35,322⑂ 2,456👁 186⑃ 300● 1,388▤ 68
PythonMPL-2.0Created 2013-12-20ocrmypdf.readthedocs.io/
下载:v17.14.1v17.14.1 ↓17.14.12026-11-09
+8
日增长
+49
周增长
35,322
stars
2,456
forks
186
watchers
300
prs
1,388
issues
68
releases

README

[![PyPI version][pypi]](https://pypi.org/project/ocrmypdf/) ![Homebrew version][homebrew] ![ReadTheDocs][docs] ![Python versions][pyversions]

[pypi]: https://img.shields.io/pypi/v/ocrmypdf.svg "PyPI version"
[homebrew]: https://img.shields.io/homebrew/v/ocrmypdf.svg "Homebrew version"
[docs]: https://readthedocs.org/projects/ocrmypdf/badge/?version=latest "RTD"
[pyversions]: https://img.shields.io/pypi/pyversions/ocrmypdf "Supported Python versions"

OCRmyPDF adds an OCR text layer to scanned PDF files, allowing them to be searched or copy-pasted.

bash
ocrmypdf                       it's a scriptable command line program
   -l eng+fra                  it supports multiple languages
   --rotate-pages              it can fix pages that are misrotated
   --deskew                    it can deskew crooked PDFs!
   --title "My PDF"            it can change output metadata
   --jobs 4                    it uses multiple cores by default
   --output-type pdfa          it produces PDF/A by default
   input_scanned.pdf           takes PDF input (or images)
   output_searchable.pdf       produces validated PDF output


See the release notes for details on the latest changes.

 Main features

- Generates a searchable PDF/A file from a regular PDF
- Places OCR text accurately below the image to ease copy / paste
- Keeps the exact resolution of the original embedded images
- When possible, inserts OCR information as a "lossless" operation without disrupting any other content
- Optimizes PDF images, often producing files smaller than the input file
- If requested, deskews and/or cleans the image before performing OCR
- Validates input and output files
- Distributes work across all available CPU cores
- Uses Tesseract OCR engine to recognize more than 100 languages
- Keeps your private data private.
- Scales properly to handle files with thousands of pages.
- Battle-tested on millions of PDFs.



For details: please consult the documentation.

 Motivation

I searched the web for a free command line tool to OCR PDF files: I found many, but none of them were really satisfying:

- Either they produced PDF files with misplaced text under the image (making copy/paste impossible)
- Or they did not handle accents and multilingual characters
- Or they changed the resolution of the embedded images
- Or they generated ridiculously large PDF files
- Or they crashed when trying to OCR
- Or they did not produce valid PDF files
- On top of that none of them produced PDF/A files (format dedicated for long time storage)

...so I decided to develop my own tool.

 Installation

Linux, Windows, macOS and FreeBSD are supported. Docker images are also available, for both x64 and ARM.

| Operating system              | Install command               |
| ----------------------------- | ------------------------------|
| Debian, Ubuntu                | apt install ocrmypdf      |
| Windows Subsystem for Linux   | apt install ocrmypdf      |
| Fedora                        | dnf install

Top issues

Discussions

Latest release

v17.14.1 v17.14.1 2026-11-09
Fixes

- Fixed the RapidOCR engine offering no way to choose where its models are
  kept. They could only live in RapidOCR's package directory, which may be
  read-only, and models downloaded into a container's directory were lost
  when it exited. The new option --rapidocr-model-dir DIR (API:
  rapidocr_model_dir=; environment: OCRMYPDF_RAPIDOCR_MODEL_DIR) keeps
  all of RapidOCR's models, and the page orientation model, in the given
  directory, downloading any that are missing into it. python -m
  ocrmypdf.builtin_plugins.rapidocr_ocr download --model-dir DIR fills it in
  advance.

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON