FreePDF logoFreePDF

OCR Gave You Garbled Text? How to Get a Cleaner Result

By the FreePDF team ·

You ran a scan through OCR, copied a paragraph, and pasted back something like “Tbe qnick hrown f0x.” Or the words are fine but half a sentence from line four has wandered into line two. OCR is guessing letters from pixels, and when it guesses badly the cause is usually the page image rather than a hidden setting.

Look at the whole text layer first

Searching in a PDF viewer only tells you whether one word was found. To see everything OCR produced, run the OCR'd file through PDF to Text and read the .txt it gives you. You'll usually spot one of three patterns:

  • A page with nothing on it. The page was sideways, too faint, or skipped entirely.
  • Real words in the wrong order. That's a layout problem: columns, tables, or a tilted page.
  • Words full of wrong letters. Blame image quality, the font, or the language.

PDF to Text also has its own “Run OCR” box. It uses the same engine as OCR PDF, so you can go straight from scan to text in one step if the .txt is all you need.

The page already had text on it

Our OCR skips any page that already contains text, so it never writes over existing words. Most of the time that's what you want. It backfires when the existing text is itself the garbage: some scanners run their own rough OCR, and some PDFs have fonts that copy out as symbols because the file never recorded which character each glyph stands for. Our tool sees text, leaves the page alone, and hands the same mess back.

The workaround is to flatten the pages into plain images first:

  1. Convert the PDF with PDF to JPG, choosing High (300 DPI).
  2. Put the JPGs back into one PDF with JPG to PDF. Check the order before converting, because Sort by Name puts page_10 ahead of page_2. The up and down arrows fix that.
  3. Run OCR PDF on the new file.

The flattened copy loses links and form fields, so keep the original. If you're comfortable on the command line, ocrmypdf (the open-source tool behind ours) has --force-ocr and --redo-ocr flags for exactly this case.

The language isn't English

There's no language setting to change here. Our OCR reads English only. French or German pages come through partly readable, with accented letters dropped or swapped for lookalikes. Chinese, Arabic, Russian, and other non-Latin scripts come out as junk or not at all. For those, use OCR software with the right language pack installed. With ocrmypdf on your own machine that's the -l option, as in -l deu for German.

Fix the scan, not the settings

Tesseract, the engine doing the recognition, works best on clean, straight pages at around 300 dpi. Most garbled output traces back to one of these:

  • Low resolution or blur. Rescan at 300 dpi, or 400 for small print. Enlarging a blurry image afterwards doesn't bring the detail back.
  • A crooked page. We don't straighten pages before reading them, and even a few degrees of tilt can split lines apart and splice pieces of different lines together. Rescan it straight, or use a scanner app that auto-crops and flattens.
  • Sideways or upside-down pages. These aren't auto-rotated either. Run the file through Rotate PDF first, keeping in mind it turns every page.
  • Low contrast. Faded carbon copies, pencil, and coloured paper all make letters harder to separate from the background.

What OCR reads badly no matter what

Handwriting is the big one. Tesseract is built for printed text, and cursive notes in the margin turn into noise. Script and heavy display fonts cause similar trouble, as does text printed over a photo or a patterned background. Tables and multi-column pages often get every character right yet read straight across the columns, so the text is searchable but reads like nonsense when copied. For anything like that, OCR gets you search; retyping is still the way to get exact text.

Common questions

Will running OCR a second time improve it?

No. The second pass finds the text layer from the first one and skips every page. Flatten the file as described above, or better, start from a cleaner scan.

Why do 0 and O, or 1 and l, keep getting mixed up?

At low resolution those characters are nearly identical shapes, and the engine has to pick one. A sharper scan helps a lot. For invoice totals, account numbers, and anything else where one wrong digit matters, check the OCR text against the page image before you rely on it.

Related free tools