OCRmyPDF
Install OCRmyPDF and Tesseract to create searchable PDFs from scanned documents.
ansible-playbook -i inventory -K playbooks/lab-stack.yml --tags ocr🔧 Manual setup and configuration
- Log out and log back in after running the role so Nautilus/Nemo reload user actions.
- In Nautilus, right-click a PDF and use OCR PDF (ocrmypdf).
- The action runs
~/.local/bin/ocrmypdf-wrapperand writes*_ocr.pdfnext to the original file. - The wrapper defaults to German + English OCR (
-l deu+eng) and skips pages that already contain text. - Review
~/.cache/ocrmypdf-wrapper.logif conversion fails.
✅ Check
ocrmypdf --version
tesseract --versionExpected: both commands print a version.
echo "test" > /tmp/ocr-test.txt
enscript /tmp/ocr-test.txt -o - | ps2pdf - /tmp/ocr-test.pdf
ocrmypdf -l eng /tmp/ocr-test.pdf /tmp/ocr-test_ocr.pdf
pdfinfo /tmp/ocr-test_ocr.pdf | sed -n '1,5p'Expected: /tmp/ocr-test_ocr.pdf is created successfully.
ls -l ~/.local/share/file-manager/actions/ocrmypdf.desktop
ls -l ~/.local/share/nemo/actions/ocrmypdf.nemo_actionExpected: at least one action file exists (depending on your file manager).
Nautilus right-click action behavior
- Menu entry:
OCR PDF (ocrmypdf) - File type: appears for PDF files (
application/pdf) - Execution: calls
~/.local/bin/ocrmypdf-wrapper "%f" - Output naming: input
paper.pdfbecomespaper_ocr.pdf - Batch behavior: the wrapper accepts multiple files and processes each one in sequence
- Troubleshooting: if the menu entry does not appear, restart Nautilus (
nautilus -q) or relogin
Why this software?
OCRmyPDF is preferred for the workstation setup because it runs locally, adds a searchable text layer while preserving the original PDF, and provides a mature command-line workflow for rotation, deskewing, optimization, and PDF/A output. It also works without an account, API key, document upload, or separate model service and integrates directly with the automated file-manager action above.
Consider an alternative when the task is broader than making scanned PDFs searchable:
- Mistral OCR can extract document structure and content for downstream AI workflows. It is a hosted API, so review costs, credentials, and data-handling requirements before uploading research or institutional documents.
- PaddleOCR provides trainable, deep-learning OCR and document-layout models for many languages and complex extraction pipelines. It requires more model/runtime setup, and producing a searchable archival PDF needs additional pipeline work.
- Baidu Unlimited OCR is a managed OCR option for high-volume or application-integrated extraction. It requires a Baidu cloud account and sending documents to an external service; confirm current service limits, pricing, supported regions, and privacy terms before use.