Tools,

OCRmyPDF language: set -l, or lose the accents

33.6%

of accented words found with no -l

Try it on your PDF, $0.006 a page

Set the language with -l

You want Run
French ocrmypdf -l fra in.pdf out.pdf
French and English ocrmypdf -l fra+eng in.pdf out.pdf
The installed list tesseract --list-langs

88.7% of accented words, right -l

93.0% of all words, right -l

14 real book scans in French, Spanish and Portuguese. With no -l, all words came to 84.1%.

No -l means English, and accents go

Accented words found
Scans No -l Right -l
French, 6 pages 48.3% 86.1%
Spanish, 4 pages 13.5% 89.9%
Portuguese, 4 pages 11.6% 96.5%
Whole-word search hits in the output PDF
Word No -l Right -l
à, 42 in the French text 0 40
más, 5 in the Spanish text 0 5
não, 10 in the Portuguese text 0 10

In place of à, it wrote a, A, & or 4. In place of não, it wrote nao. Every run exited 0.

A wrong code stops with exit 3

You typed Exit
-l fr, -l french, -l FRA 3
-l eng,fra, -l "eng fra" 3
-l fra, French not installed 3
-l eng+fra, -l eng -l fra 0
OCR engine does not have language data for the following requested languages:
fr

Use Tesseract's lower-case codes: fra, spa, por, deu, chi_sim.

System Get French
macOS, Homebrew brew install tesseract-lang
Debian, Ubuntu apt-get install tesseract-ocr-fra

I did not run these two here. The apt line ran on Debian for Tesseract.

Your own model folder: exit 9

I pointed TESSDATA_PREFIX at a folder of .traineddata files. Every run with a valid code stopped, exit 9:

[tesseract] read_params_file: Can't open hocr
TesseractConfigError: Error occurred while parsing a Tesseract configuration file

OCRmyPDF needs Tesseract's configs folder there too. This ran as printed, exit 0:

mkdir -p ~/tessdata
cp fra.traineddata ~/tessdata/
cp -R "$(brew --prefix)/share/tessdata/configs" ~/tessdata/
TESSDATA_PREFIX=~/tessdata ocrmypdf -l fra in.pdf out.pdf

OCRed with no -l? Use --redo-ocr

The French file OCRed with no -l, then -l fra
Flag Exit Accented words
none 6 Stopped, page has text
--skip-text 0 48.3%, old layer kept
--redo-ocr 0 86.1%
--force-ocr 0 86.1%

That is the same as -l fra on the scans. More on exit 6.

English and French pages in one file

Words found, 6 pages of each
-l English pages French pages
none 95.0% 82.9%
fra 94.3% 90.6%
eng+fra 95.3% 91.1%
fra+eng 95.3% 91.2%

List both languages. The order made almost no difference here.

From Python: language takes a list

import sys

import ocrmypdf

code = ocrmypdf.ocr(sys.argv[1], sys.argv[2], language=["fra", "eng"])
print("exit:", code)
exit: 0

language="fra+eng" also gave 213 words. A missing language raises MissingDependencyError, exit code 3.

Our Actor: pick the language, send scans

PDF OCR to Markdown, our Apify Actor, has a language box with 10 choices, one per run.

Actor build 0.1.35 code on this Mac, accented words
Scans English Their language
French 48.3% 89.1%
Spanish 13.5% 87.2%
Portuguese 11.6% 94.2%

Questions people ask

Does OCRmyPDF detect the language?

Not here. With no -l, it gave the same text as -l eng on the French pages, byte for byte.

Where is the OCRmyPDF language list?

Run tesseract --list-langs. Here, Homebrew's Tesseract listed only eng, osd and snum.

Should I list more languages to be safe?

Not here. eng+fra+spa+por+deu on the French pages found 82.8% of accented words, fewer than fra alone.

Method, limits and sources

How I tested it

14 printed book pages from 10 Wikisource books, each page checked by two people. A seeded shuffle picked the books, not me. The mixed file adds 6 English pages from 3 more books.

One run per setting, default settings. Words found counts true words in any order, exact case, and extra words cost nothing. Accented words have a letter outside A to Z.

I read the output PDFs with pdftotext. The Actor is build 0.1.35's own page code, run on this Mac. Scripts and results are in research/bench/ocrmypdf-language-2026-11-02/.

What I did not test
  • German, Russian, Chinese and Arabic scans.
  • Old type such as Fraktur, and handwriting.
  • The larger tessdata_best models.
  • Windows, Linux and Docker. Speed: single runs vary.
Versions and sources
  • OCRmyPDF 17.13.0 (MPL 2.0) and Tesseract 5.5.3, on one Mac.
  • tessdata_fast 4.1.0 models and Poppler pdftotext 26.03.0.
  • OCRmyPDF language documentation
  • Page scans and text: Wikisource.
  • We make the Apify Actor. The other tools are open source, and we do not make them.