OCRmyPDF’s manual says –pages limits OCR to the specified pages, using ranges or comma-separated lists, with ‘end’ as an alias for the last page. A short test run is how you find a wrong language or a bad scan before processing hundreds of pages.
Use the practice file
A practice document, practice-long-book.pdf. The file is fictional.
| Page | Content |
|---|---|
| 1–3 | Opening chapters, clean scans |
| 4 | Chapter with a faded page, including the word “harvest” |
| 5–40 | Remaining chapters |
Page 4 is the check page: the word “harvest” appears there once, on a faded page.
Check the page-range test
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. Run OCR on pages 1–4 only
Run ocrmypdf –pages 1-4 practice-long-book.pdf test.pdf.
Expected result: OCRmyPDF processes four pages and skips the rest.
2. Check the faded page
Copy page 4 of test.pdf and compare it with the scan.
Expected result: Count the errors on the faded page before deciding anything.
3. Search for the key word
Use Find for “harvest” in test.pdf.
Expected result: 1 hit, on page 4.
4. Decide on the full run
If page 4 reads cleanly, run the whole file; if not, fix the scan or the language first.
Expected result: The decision is made from the four-page sample, not from hope.
Verdict table
| Check | Expected result | Pass? |
|---|---|---|
| Run OCR on pages 1–4 only | OCRmyPDF processes four pages and skips the rest. | — |
| Check the faded page | Count the errors on the faded page before deciding anything. | — |
| Search for the key word | 1 hit, on page 4. | — |
| Decide on the full run | The decision is made from the four-page sample, not from hope. | — |
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
- A four-page test that fails saves a forty-page re-run; a test that passes on clean pages says nothing about the faded ones, so include a hard page in the sample.
- 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.
