OCRmyPDF’s manual says –redo-ocr detects and removes the hidden OCR layer from files previously OCRed, then applies OCR to the raster images, while existing visible text objects are not changed.
Use the practice file
A practice document, practice-old-ocr.pdf. The file is fictional.
| Page | Content |
|---|---|
| 1 | Scanned page with a bad old layer: the word “harvest” is stored as “harvset” |
| 2 | Scanned page with a bad old layer: the total “42” is stored as “4Z” |
| 3 | Born-digital text page, correct |
Page 1 is the check page: the visible word is “harvest” but the old layer stores “harvset”.
Check redo-ocr
Expected result. We checked the OCRmyPDF manual and the Tesseract manual. We did not run any tool. The checks below are what to expect if the work is done correctly; run them yourself on the practice file.
1. Prove the old layer is bad
Use Find for “harvest” in the original.
Expected result: 0 hits, because the layer stores “harvset”.
2. Run OCR with –redo-ocr
Run ocrmypdf –redo-ocr practice-old-ocr.pdf out.pdf.
Expected result: OCRmyPDF replaces the old layer.
3. Search again
Use Find for “harvest” in out.pdf.
Expected result: 1 hit, on page 1.
4. Check the total
Use Find for “42” in out.pdf.
Expected result: 1 hit, on page 2, and the visible text on page 3 is unchanged.
Verdict table
| Check | Expected result | Pass? |
|---|---|---|
| Prove the old layer is bad | 0 hits, because the layer stores “harvset”. | — |
| Run OCR with –redo-ocr | OCRmyPDF replaces the old layer. | — |
| Search again | 1 hit, on page 1. | — |
| Check the total | 1 hit, on page 2, and the visible text on page 3 is unchanged. | — |
Related guides: How to Batch OCR a Multi-Page PDF with Consistent Settings — How to Add a Searchable Text Layer to a Scanned PDF.
Limits
- Redo-ocr is for a bad invisible layer, not for bad visible text: if the page image itself is wrong, no OCR mode can fix it.
- Command-line OCR rewrites the file, so always work on a copy and keep the original scan untouched.
- UNTESTED — no OCR tool was run; all results above are expected results. The practice file is fictional.
Sources
- OCRmyPDF manual, “ocrmypdf(1) — add an OCR text layer to scanned PDF files” — Modes default, force, skip, redo and strip; –sidecar writes the recognized text; –pages limits OCR to chosen pages. Checked 2026-11-28.
- Tesseract manual, “tesseract(1) — command-line OCR engine” — Default language is English; -l takes 3-character ISO 639-2 codes, joined with + for several languages; –list-langs lists installed packs; –psm sets the page segmentation mode. Checked 2026-11-28.
