New Tool Radar

AI PDF

How to OCR a PDF Containing Two Languages With Tesseract and Check Both Were Recognised

Run Tesseract with both language codes joined by a plus sign, then check each language section separately.

Schematic with three steps: Confirm both language packs are installed; Run OCR with both codes; Check each language section.

A document that mixes two languages, such as an English report with French quotations, needs both language data files at once. Tesseract accepts several languages joined with a plus sign, for example eng+deu+fra, and the order of the codes affects the result, so check each language section on its own.

What you need

  • Tesseract installed with both language packs
  • A scanned page containing two languages
  • The three-character codes for both languages

Step 1: Confirm both language packs are installed

Run tesseract –list-langs and confirm both codes appear. Install any missing pack before the OCR run.

Step 2: Run OCR with both codes

Run Tesseract with -l and the two codes joined by a plus sign, for example tesseract page.png output -l eng+fra, and open the output.

Step 3: Check each language section

Read the English section and the French section separately against the page. Check accented words in the French section and proper names in both.

Worked example: synthetic two-language OCR check

The table below is a synthetic example. It shows the expected result of checking two-language OCR; no OCR was run.

Section Words correct, eng only Words correct, eng+fra
English paragraph 19 of 20 20 of 20
French paragraph 6 of 20 19 of 20
Mixed heading 1 of 2 2 of 2

Expected result (UNTESTED). with English only, the French paragraph scores 6 of 20 words, while with eng+fra it scores 19 of 20 and the English paragraph stays at 20 of 20. Use both codes for mixed documents. This check was not run live; the table shows the expected result for the synthetic example.

Limits

  • Multiple languages are separated by plus characters, and the order can change the output.
  • Selecting a script also selects its character set and dictionary, which can help a language without its own trained data.
  • Check both sections; a good score in one language does not prove the other was recognised.

Sources

See all