Plain text loses the layout, but hOCR keeps it: the output is HTML that records the bounding box of every word, line and paragraph. That is what you need when a later step has to know where on the page a word sits. The Tesseract documentation lists hOCR among its output formats. This guide runs it on one scanned page.
Prerequisites
Tesseract 5.5 installed and a scanned page as an image. Work on a copy of the scan.
Steps
1. Check the Tesseract version
Run tesseract –version in a terminal. Expected result: the version prints as 5.5.x with Leptonica.
2. Run Tesseract with hOCR output
Run tesseract scan.png output hocr. Expected result: a file named output.hocr is created.
3. Open the hOCR file and find a word
Open output.hocr in a text editor and search for the word harvest. Expected result: the word appears inside a span with a bbox attribute giving its box coordinates.
4. Check the box sits on the right line
Read the bbox numbers and confirm the word sits on the first line of the page. Expected result: the box coordinates place harvest on line one.
Practice check: fictional one-page scan of a letter, word harvest on line one
The table below is fictional practice material. It lists the four checks for the hOCR file.
| Check | Expected result |
|---|---|
| Version printed | 5.5.x with Leptonica |
| Output file created | output.hocr exists |
| Word found in file | harvest inside a span |
| Box on line one | bbox on the first line |
Expected result. the hOCR file is created, the word harvest appears with a bbox attribute, and the box sits on the first line of the page.
Limits
- hOCR boxes describe where Tesseract thinks the word is, not where it truly is; a skewed scan shifts every box, so deskew first when boxes matter.
- UNTESTED – no OCR tool or AI tool was run; all results above are expected results. The practice file is fictional.
Sources
- 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.
- Tesseract OCR – Version 5.5.3 with Leptonica; searchable PDF output and TSV word confidence are built in. Checked 2026-11-29.
