Docling with Tesseract: tesserocr or the CLI
ocr_options=TesseractCliOcrOptions(lang=["eng"])
Same Tesseract version and model. The CLI engine found 95.9% of our scan's words, tesserocr 94.2%.
CLI engine and our Actor led
| Reader | Words found |
|---|---|
| Docling + tesseract CLI | 1,875 (95.9%) |
| Docling + tesserocr | 1,841 (94.2%) |
| Docling default (RapidOCR) | 1,855 (94.9%) |
| Tesseract alone (OCRmyPDF) | 1,853 (94.8%) |
| Our Actor | 1,877 (96.0%) |
10 scanned book pages from Wikisource. A word counts as found when it is right and in the right order.
Why tesserocr found fewer words
- Line by line. Docling's tesserocr code finds each text line in a block, then reads it alone. The CLI code reads each block in one tesseract run.
- Reading line by line cost 37 words. I read whole page images with tesserocr both ways: line by line 1,841 words, in one run 1,878.
- The DPI did not matter here. The CLI engine gets a PNG marked 216 dpi, tesserocr no DPI. With 216 dpi set, tesserocr found 1,878 again.
TesseractOcrOptions in Python
pip install docling tesserocr
from docling.datamodel.base_models import InputFormat
from docling.datamodel.pipeline_options import PdfPipelineOptions, TesseractOcrOptions
from docling.document_converter import DocumentConverter, PdfFormatOption
options = PdfPipelineOptions(ocr_options=TesseractOcrOptions(lang=["eng"]))
converter = DocumentConverter(
format_options={InputFormat.PDF: PdfFormatOption(pipeline_options=options)}
)
print(converter.convert("scan.pdf").document.export_to_markdown())
Save it as docling_tesseract.py next to scan.pdf. Run it with the folder that holds eng.traineddata:
TESSDATA_PREFIX=/opt/homebrew/share/tessdata python3 docling_tesseract.py > scan.md
That is Homebrew's folder on an Apple Silicon Mac. Elsewhere, use
the folder that tesseract --list-langs prints.
For the CLI engine, write TesseractCliOcrOptions in the import and in the options line. It needs no TESSDATA_PREFIX.
From the command line
docling convert scan.pdf --ocr-engine tesseract --ocr-lang eng
It writes scan.md in the current folder. For tesserocr, use
--ocr-engine tesserocr and set TESSDATA_PREFIX first.
4 start errors, and their fixes
-
"tesserocr is not correctly installed"
Docling could not import tesserocr. Run
pip install tesserocr: 2.13.0 has wheels for macOS, Linux and Windows. Or use the CLI engine. -
"tesserocr is not correctly configured"
Our tesserocr wheel looked in ./ and found no language files. Point
TESSDATA_PREFIX at a folder with eng.traineddata, or pass it as
path=. -
OcrLanguageNotSupportedError Both engines ask for
English, Spanish, French and German by default. Homebrew's
Tesseract has English only. Set
lang=["eng"]. -
"Tesseract is not available, aborting"
The CLI engine could not run tesseract. Install it, or set
tesseract_cmdto its full path.
Our Actor reads scans with no setup
PDF OCR to Markdown, our Apify Actor, found the most words on the same scan.
No Python and no tessdata folder: send the PDF, get Markdown back.
- Scanned pages: $0.006 each. Digital pages: free. Plus a $0.00005 start fee a run at the default 1 GB.
- On Apify's free plan, it stops at 20 pages a run and 50 a month.
What I did not test
- Other languages, and an empty lang, which makes Tesseract detect the script.
- PDFs with a text layer, and the OCR modes for them.
- Other scales than Docling's default of 3.
- Linux, Windows and the server: docling-serve OCR.
How I tested it
- 10 proofread book pages from 2 Wikisource books, as a 300 ppi image-only PDF: the scan of count words in a PDF. 1,955 words. The OCRmyPDF and Actor rows come from that test.
- Words found: proofread words found in order in Docling's export_to_text. Its Markdown gave the same counts.
- Each engine ran in a fresh Python process with Docling's defaults, at nice 19 and background priority, 4 threads. The two Tesseract engines got lang=["eng"]. The default ran untouched.
- No speed ranking: the Mac was busy, and two warm runs of tesserocr took 2.4 and 4.4 s a page.
- The Actor row is its code (build 0.1.125) run on our Mac, with text output.
- Docling 2.151.1, docling-core 2.108.0, tesserocr 2.13.0 (its own Tesseract 5.5.4), Homebrew Tesseract 5.5.4, eng.traineddata from tessdata_fast 4.1.0, torch 2.15.0, RapidOCR 3.10.0, Python 3.12.12 (arm64), macOS 26.6.
- The first run of each engine waited minutes (404 s for the first import) while macOS checked each new library once. The reruns in the table did not wait.
- Scripts and results stay in our private repo, in research/bench/docling-tesseract-2026-11-22/.
Sources
- Docling installation docs (the OCR engines)
- tesserocr
- Tesseract
- We make the Apify Actor, and none of the other tools here.
Questions people ask
How do I use Tesseract with Docling?
Set ocr_options=TesseractCliOcrOptions(lang=["eng"]) in PdfPipelineOptions, or TesseractOcrOptions for tesserocr. From the command line: docling convert scan.pdf --ocr-engine tesseract --ocr-lang eng.
tesserocr or the tesseract CLI: which is better in Docling?
On our scan the CLI engine found 1,875 of 1,955 words and tesserocr 1,841, with the same Tesseract version and model. The CLI engine also needs no TESSDATA_PREFIX.
How do I fix "tesserocr is not correctly configured"?
tesserocr found no language models: our wheel had none. Set TESSDATA_PREFIX to a folder with eng.traineddata, like the one tesseract --list-langs prints (/opt/homebrew/share/tessdata on our Mac), or pass that folder as path= to TesseractOcrOptions.
Does Docling use Tesseract by default?
No. It takes the first installed engine that fits. On a Mac: ocrmac, RapidOCR with onnxruntime, EasyOCR, then RapidOCR with torch. A plain pip install docling on our Mac used RapidOCR with torch.
Two ways to skip the work
Run it yourself. Our Apify Actor turns scanned PDFs into Markdown, tables included.
Or send us the scan. Tack, our AI, does the job for $29, up to 50 pages. First page free.