OCRmyPDF can write the recognised text to a companion text file, called a sidecar, at the same time as it builds the searchable PDF. The sidecar is what a search index or a script reads, without opening the PDF. The OCRmyPDF cookbook shows the –sidecar option. This guide runs it on one scanned PDF.
Prerequisites
OCRmyPDF installed with Tesseract, and a scanned PDF. Work on a copy of the file.
Steps
1. Check the OCRmyPDF version
Run ocrmypdf –version in a terminal. Expected result: a version number prints.
2. Run OCRmyPDF with a sidecar
Run ocrmypdf –sidecar output.txt input.pdf output.pdf. Expected result: output.pdf and output.txt are both created.
3. Open the sidecar and find a word
Open output.txt and search for the word harvest. Expected result: the word appears in the sidecar text.
4. Check the sidecar matches the PDF text
Select the same word in output.pdf and compare. Expected result: the word appears in both the sidecar and the PDF text layer.
Practice check: fictional two-page scan of a letter, word harvest on page 1
The table below is fictional practice material. It lists the four checks for the sidecar file.
| Check | Expected result |
|---|---|
| Version printed | A version number prints |
| Files created | output.pdf and output.txt |
| Word in sidecar | harvest present |
| Word in PDF layer | harvest selectable |
Expected result. both files are created, and the word harvest appears in the sidecar text and in the PDF text layer.
Limits
- The sidecar only holds text OCRmyPDF recognised; pages that already had text are not included, so do not treat the sidecar as the full document text.
- UNTESTED – no OCR tool or AI tool was run; all results above are expected results. The practice file is fictional.
Sources
- OCRmyPDF Cookbook – –sidecar writes OCR text to a companion file; –output-type pdfa/pdf picks the output; –optimize shrinks the file; –mode strip removes the text layer. Checked 2026-11-29.
- Tesseract OCR Documentation, output formats – Tesseract supports plain text, searchable PDF, hOCR, TSV, ALTO and PAGE output; –psm sets the page segmentation mode. Checked 2026-11-29.
