How to Extract Text from an Image or Scanned PDF (OCR That Actually Works)
OCR accuracy is decided before you run it. Here is how resolution, contrast and straightness change the result, and how to get clean text out of a photographed page.
Updated August 11, 20265 min read
Optical character recognition has quietly become very good — good enough that when it fails, the cause is almost always the input rather than the engine. A photo taken at an angle in poor light will produce garbage from any OCR system on earth. Five minutes spent on the image beforehand routinely takes accuracy from roughly 70% to well above 95%, which is the difference between text you can use and text you have to retype.
What OCR is doing
The engine works in stages: find the regions of the image that contain text, work out the line and word boundaries, segment individual characters, then classify each shape against a model of what letters look like. A language model cleans up the result afterwards, which is why rn correctly becomes m in a real word but not in a serial number.
Every stage depends on the one before it. If line detection fails because the page is tilted, character segmentation gets nonsense to work with and no amount of clever classification recovers it. This is why input quality dominates.
The four things that decide accuracy
| Factor | What to aim for | Why |
|---|---|---|
| Resolution | 300 DPI — about 2500px across an A4 page | Below this, characters have too few pixels to distinguish |
| Straightness | Within 1–2° of level | Line detection degrades quickly with skew |
| Contrast | Dark text, bright even background | Low contrast blurs the character boundary |
| Flatness | No curve, no keystoning | Curved lines break the line-detection stage |
Resolution is the one people get wrong most often. A phone screenshot of a document at 800px wide simply does not contain enough pixels per character for reliable recognition, no matter how sharp it looks. If you can, capture again at higher resolution rather than trying to rescue what you have.
Preparing an image for OCR
Straighten it
Even a few degrees of tilt hurts. The image straightening tool detects the angle automatically or lets you set it by hand.
Correct the perspective
A page photographed from above at an angle is a trapezoid, not a rectangle, and the text lines converge. Perspective correction pulls the four corners back to a rectangle.
Crop to the text
Remove the desk, the fingers holding the page, and the shadow at the edge. Anything that is not text is something the region-detection stage has to rule out.
Raise the contrast if it is flat
A pale scan or a photo taken in dim light benefits from a contrast bump in the image enhancer. Do not go so far that thin strokes break up.
Then run OCR
Feed the cleaned image to image to text. Comparing the output against your first attempt is usually a striking difference.
Recognition runs on your own device — invoices, contracts and ID documents are never uploaded.
Extract text from an imageScanned PDFs are a different job
First check whether OCR is needed at all. Open the PDF and try to select a line of text. If it highlights, the text layer already exists and you should extract it directly rather than re-recognising pictures of it — extraction is exact, OCR is a guess.
If the cursor draws a box over an image instead, every page is a picture and PDF to text will run recognition across them. Multi-page documents take proportionally longer, so test on a single page first (split one off) before committing to two hundred.
One quirk worth knowing: some PDFs have a text layer that is itself the output of a bad OCR pass from years ago. The text selects, but it is wrong. In that case re-rendering the pages to images with PDF to image at 300 DPI and re-running recognition gives a better result than trusting what is there.
What OCR still struggles with
- Handwriting. Printed-text OCR and handwriting recognition are different problems. Expect poor results on cursive, and mixed results on neat block capitals.
- Complex tables. The characters are usually read correctly; the structure is not. Column boundaries and merged cells frequently come out scrambled, so expect to rebuild the layout by hand.
- Multi-column layouts. Newspapers and academic papers often get read straight across the columns, interleaving two unrelated sentences.
- Stylised and decorative type. Logos, script fonts and heavily letterspaced headings are outside what the character model expects.
- Low-contrast documents. Faded thermal receipts, carbon copies and pale photocopies lose the character boundary the segmentation stage needs.
Whatever the source, proofread the output. Even at 98% character accuracy, a page of 2,000 characters carries around forty errors — and OCR mistakes cluster in exactly the places where they matter, such as digits in reference numbers and account details.
Because recognition runs entirely on your own device, none of this content reaches a server. That matters for the documents people most often want to convert: invoices, bank statements, medical letters and identity papers.
Frequently asked questions
How accurate is OCR?
On a clean 300 DPI scan of printed text, well above 98% character accuracy. On an angled phone photo in poor light it can drop below 70%. The gap is almost entirely down to the input — straightening, cropping and capturing at higher resolution matter more than which engine you use.
Can OCR read handwriting?
Not reliably. Printed-text recognition and handwriting recognition are different problems, and general OCR is built for the former. Neat block capitals sometimes work; cursive generally does not.
Why is my OCR output full of nonsense characters?
Usually resolution or skew. If the image is well under 300 DPI — about 2500px across an A4 page — characters have too few pixels to distinguish. If it is tilted more than a couple of degrees, line detection fails and everything downstream inherits the error.
Is it safe to OCR confidential documents online?
Only if the tool runs locally. Ours performs recognition on your own device, so invoices, contracts and identity documents are never transmitted — which is exactly the category of file people most often need to convert.