OCRmyPDF "page already has text": which flag to use
0.4%
of words found by --skip-text on stamped scans
Try it on your PDF, $0.006 a page
Pick the flag by what is inside
| Your PDF | Use |
|---|---|
| Typed pages and scans, mixed |
--skip-text or --redo-ocr. Both kept
the typed pages and read the scans
|
| Scans with one typed line, like a stamp | --redo-ocr |
| OCRed before |
--skip-text keeps the old text.
--redo-ocr reads it again
|
| All typed, like a Word export | No OCR needed. --skip-text keeps its text |
ocrmypdf --redo-ocr in.pdf out.pdf
Exit code 6: a page has text
PriorOcrFoundError: page 1 already has text! - aborting (use --force-ocr or --mode force to force OCR; see also help for --skip-text, --redo-ocr, and --mode)
OCRmyPDF stops when a page already has text, typed or from an older OCR run. Nothing broke: pick a flag from the table above.
A PDF marked as Tagged stops with TaggedPDFError, also
exit code 6. The same three flags ran on it. Its message says
--force-ocr and --redo-ocr drop the tags on
pages they redo.
--skip-text skipped my stamped scans
One typed line on top, "Received Nov 2, 2026. Page 1 of 4", was enough. OCRmyPDF logged this for each page:
1 skipping all processing on this page
Check one page before you pick a flag:
pdftotext -f 1 -l 1 in.pdf -
Received Nov 2, 2026. Page 1 of 4
Only a line or two from a full page? That is the stamp row in the table.
--force-ocr turns typed text into pictures
57x bigger: 4 typed pages, 5 KB to 296 KB
97.8% of typed words found, was 100%
- The typed text was gone from all 4 pages. Only an OCR layer was left.
- It also saved each scan again as a new, smaller JPEG at the same pixel size.
From Python: catch it, then redo
import ocrmypdf
from ocrmypdf.exceptions import PriorOcrFoundError
try:
ocrmypdf.ocr("in.pdf", "out.pdf")
except PriorOcrFoundError:
code = ocrmypdf.ocr("in.pdf", "out.pdf", redo_ocr=True)
print("redone:", code)
redone: 0
skip_text=True, force_ocr=True and
mode="redo" also ran.
Want text, not a PDF? Try our Actor
PDF OCR to Markdown, our Apify Actor, reads typed pages as they are and runs Tesseract on scans.
| Pages | Actor |
|---|---|
| Typed | 100% |
| Scans | 91.5% |
| Scans with one typed line | 91.5%, the line kept too |
| OCRed before by OCRmyPDF | 57.7%: it read the old hidden text, letters spaced out |
-
PyMuPDF read that hidden text at 91.4%. The Actor cannot OCR it
again, so use
--redo-ocr. - It gives text or Markdown, not a searchable PDF. Files upload to your Apify run, and go to no LLM or other API.
- Each run also costs $0.00005 at the default 1 GB.
- The Apify free plan lets you try 20 pages a run and 50 a month.
Questions people ask
Is exit code 6 a failure?
It stopped on purpose. In my runs it wrote no output file.
Will --redo-ocr double the text?
Not in my runs. On 4 scans that were OCRed before, each page had the same word count after --redo-ocr.
Can I use --deskew with --redo-ocr?
No. OCRmyPDF 17.13.0 said: --redo-ocr (or --mode redo) is not currently compatible with --deskew, --clean-final, and --remove-background. --force-ocr ran with --deskew. --skip-text --deskew ran too, but it skips any page with text.
What is --mode?
Its help says --mode skip, redo and force match the three flags, and --mode strip removes the hidden OCR text. I ran --mode redo, and it worked like --redo-ocr.
Method, limits and sources
How I tested it
I made 6 small PDFs on purpose: 4 typed pages, 4 book scans at 300 dpi, the two mixed, the scans with one typed line on each, the typed pages marked as a Tagged PDF, and the scans after one OCRmyPDF run.
Each file ran with no flag, then with each of the three flags, at OCRmyPDF's default settings. Words found counts the true words in order, against the proofread Wikisource text.
The Actor is build 0.1.34's own page code, run on this Mac. It ran on 5 of the 6 files. Scripts and results are in research/bench/ocrmypdf-prior-ocr-2026-11-02/.
What I did not test
- Real scanner files.
- An old OCR layer that is wrong.
- Windows, Linux and Docker.
- Signed PDFs and forms.
Versions and sources
- OCRmyPDF 17.13.0 (MPL 2.0), Tesseract 5.5.3, Poppler pdftotext, PyMuPDF to build and read the files. One Mac.
- OCRmyPDF documentation
- OCRmyPDF on GitHub
- We make the Apify Actor. The other tools are open source, and we do not make them.