Scanned pages are often tilted or upside down, and OCR accuracy falls sharply on skewed text. OCRmyPDF can straighten tilted pages with –deskew and detect and correct page orientation with –rotate-pages before recognising the text.
What you need
- OCRmyPDF and Tesseract installed, with unpaper for cleanup
- A scanned PDF with tilted or rotated pages
- A note of which pages are upside down or sideways
Step 1: Run OCRmyPDF with deskew and rotation
Run ocrmypdf with the language code, –deskew and –rotate-pages, for example ocrmypdf -l eng –deskew –rotate-pages tilted.pdf fixed.pdf.
Step 2: Check the page orientation
Open the output and confirm every page is upright and level, including the pages you noted as rotated.
Step 3: Check the text order
Select and copy a paragraph from a fixed page and confirm the lines read top to bottom in the right order.
Worked example: synthetic deskew check on a tilted scan
The table below is a synthetic example. It shows the expected result of deskewing a scan; no OCR was run.
| Check | Before fix | After fix |
|---|---|---|
| Pages upright | 9 of 12 | 12 of 12 |
| Tilted pages straight | 0 of 3 | 3 of 3 |
| Lines in correct order | 7 of 12 | 12 of 12 |
Expected result (UNTESTED). after –deskew and –rotate-pages all 12 pages are upright, all 3 tilted pages are straight, and all 12 pages read in the correct order. Check orientation on every page, not just the first. This check was not run live; the table shows the expected result for the synthetic example.
Limits
- –clean needs unpaper installed; without it the cleanup step is skipped.
- Deskew corrects tilt, but it cannot repair a page that is badly creased or out of focus.
- Try the run on a few pages first with –pages before committing a long document.
