When a field should contain only digits, letting Tesseract consider the whole alphabet invites mistakes such as reading 0 as O or 1 as l. A character whitelist restricts the recogniser to the digits you allow, which removes a whole class of errors from numeric fields such as totals, dates, and reference numbers.
What you need
- Tesseract installed
- A cropped image of a numeric field, such as an invoice total
- The correct value of the field, read from the page by eye
Step 1: Crop the field
Crop the image to just the numeric field so no nearby letters can confuse the recogniser.
Step 2: Run Tesseract with a whitelist
Run tesseract field.png out -c tessedit_char_whitelist=0123456789., and read the output. The -c option sets a configuration variable for the run.
Step 3: Compare with the value you read by eye
Check the recognised digits against the value you read from the page. If they match, the whitelist worked; if not, check the crop and the image quality.
Worked example: synthetic whitelist check on an invoice total field
The table below is a synthetic example. It shows the expected result of whitelisting digits; no OCR was run.
| Field | Without whitelist | With whitelist |
|---|---|---|
| Invoice total | 1,2O4.50 | 1,204.50 |
| VAT number | GB12345678O | GB123456780 |
| Date | 12/03/2O26 | 12/03/2026 |
| Reference | INV-0042 | INV-0042 |
Expected result (UNTESTED). without a whitelist the total reads as 1,2O4.50 with a letter O in place of a zero, while the whitelist run reads 1,204.50 correctly. Note the VAT number still needs letters, so a digit-only whitelist does not suit every field. This check was not run live; the table shows the expected result for the synthetic example.
Limits
- A whitelist that is too narrow removes characters the field actually needs, such as letters in a VAT number.
- The whitelist only helps if the image is clean; a blurry digit can still be misread as another digit.
- Always verify the result against the page, because a whitelist can make a wrong reading look confident.
