How OCR Works: From Scanned Image to Searchable PDF Text
OCR turns pictures of text into words you can search and copy. Learn what happens at each step and why some scans come out cleaner than others.

On this page
You scanned a stack of invoices, hit Ctrl+F to find one supplier, and got nothing back. That's because a scan is a photograph of text, not text. PDF OCR (optical character recognition) is what bridges the gap: it looks at the picture, works out which shapes are letters, and gives you words you can search, copy and edit.
Here's what actually happens inside an OCR engine, why some pages come out nearly perfect while others turn to gibberish, and how to set up your scans for the cleanest result.
How does OCR work in a nutshell?
A scanned page is just a grid of pixels. OCR software studies those pixels, decides which shapes are characters, groups them into words and lines, and outputs text. With a PDF, that text is usually written into an invisible layer that sits exactly over the original image.
So the page looks the same as before, but now you can search for "Hartley Supplies", highlight a paragraph and paste it into an email, or have a screen reader read it aloud. Our article on scanned vs searchable PDFs shows the difference in practice.
Step 1: cleaning up the image
Before an engine tries to read anything, it tidies the image. It typically converts the page to pure black and white (binarisation) so the text stands out from the paper. It detects a slight tilt and rotates the page until the lines run level, a step called deskewing. It also checks whether the page is sideways or upside down, removes specks and dust marks left by the scanner, and darkens faint text.
This stage matters more than most people expect. Think of a receipt photographed at an angle under a kitchen light: shadows, curl and a skew of a few degrees. Preprocessing has to fix all of that before recognition even starts, and if it can't, the output suffers.
Step 2: working out the layout
Next the engine maps the page. It separates text blocks from photos, tables and logos. It spots columns so a two-column newsletter is read down the left column first rather than straight across. Then it breaks each block into lines and each line into words.
Layout is where many "OCR failures" really come from. A three-column brochure with text wrapped around images can have every single word recognised correctly and still come out in a scrambled order. A plain one-column letter rarely has that problem.
Step 3: recognising characters and words
This is the heart of the process. Engines have used three broad approaches over the years:
| Approach | How it works | Strengths and weaknesses |
|---|---|---|
| Pattern matching | Compares each character image with stored templates of known characters | Works for consistent, known fonts; struggles with new fonts and sizes |
| Feature extraction | Identifies features such as lines, curves, loops and intersections | More flexible across fonts; still sensitive to noise |
| Neural networks | Models trained on large amounts of text images recognise whole lines or words in context | Generally the most accurate today; quality depends on training data |
Modern engines, including widely used open-source ones such as Tesseract, use neural networks that read a whole line at a time rather than one character in isolation. Context is what helps them tell O from 0 and l from 1. In "Invoice 1042" the engine can reasonably guess the characters after "Invoice" are digits.
Step 4: checking the output against language
After the raw read, many engines refine the result using what they know about the language. A dictionary helps pick "receipt" over "rcceipt" when both are plausible readings of a smudged word. The language setting tells the engine which alphabet and accents to expect, and picking the right one makes a clear difference: a French document read as English will lose its accents and mangle words like "réservé". Some engines also produce confidence scores, flagging words they're unsure about so a tool can highlight them for review.
Note: Dictionary correction helps with ordinary sentences but can "fix" things that were never words, such as product codes, surnames or reference numbers. Proofread those carefully.
Step 5: building the searchable PDF
Last, the recognised text goes back into a document. There are two common forms.
The first keeps the original page image visible and places the recognised text invisibly on top, positioned so that selecting a word highlights the right spot on the scan. This is what most archives and offices want, because the page still looks like the original.
The second exports the text on its own, as a .txt file or as the starting point for a Word document. That's handy for reusing content, though rebuilding the layout is a separate challenge; PDF to Word: preserving formatting explains why.
Warning: The hidden layer holds real text. Drawing a black box over a name on the image doesn't remove that name from the layer underneath. Read PDF redaction vs whiteout before sharing an OCR'd file with anything sensitive in it.
What affects PDF OCR accuracy?
No engine is perfect, but the input decides most of the outcome.
| Factor | Better results | Worse results |
|---|---|---|
| Resolution | Around 300 DPI for normal text | Below about 200 DPI, or very small type |
| Contrast | Dark text on a light, plain background | Faded print, coloured or patterned backgrounds |
| Alignment | Flat, straight pages | Curved book spines, skewed photos |
| Font | Common printed fonts | Decorative, very condensed or handwritten text |
| Language | Correct language selected | Wrong or mixed languages without configuration |
| Compression | Light or no compression before OCR | Heavy JPEG artefacts around letters |
A crisp laser-printed contract scanned flat at 300 DPI will usually come out close to word-perfect. A faded thermal till receipt photographed on a phone won't, however good the engine is.
How should I prepare scans for OCR?
A few habits give the engine the best chance.
- Scan at around 300 DPI, in grayscale for ordinary documents.
- Put loose images into one PDF with JPG to PDF if you photographed pages one at a time.
- Turn pages upright with Rotate PDF. Many engines detect orientation, but starting the right way up removes a source of error.
- Drop blank pages, such as empty backs of double-sided scans, so there's less to process.
- Run OCR with the correct document language selected.
- Check the result by searching for a few words you know are there and spot-checking numbers.
- Compress afterwards if the file is too big, not before, since heavy compression blurs the letters OCR depends on.
Tip: Not sure whether a PDF already has a text layer? Run it through PDF to Text. If readable text comes out, you may not need OCR at all.
Running OCR on PdfPress
OCR PDF on PdfPress reads the text on scanned pages and adds an invisible text layer, so the file looks unchanged but becomes searchable and copyable. For a single photo or screenshot, OCR Image pulls the text out directly. Both run locally in your browser, along with the prep steps above (combining images, rotating, removing pages and compressing), so your scans stay on your own device from start to finish.
Written by PdfPress Editorial
Our editorial team writes and maintains practical guides on PDF workflows. Articles are reviewed for accuracy and updated when tools or best practices change. Spotted an error? Let us know.
Questions readers ask
Is OCR 100% accurate?
No OCR engine is perfect. Clean, high-contrast printed text is usually recognised very accurately, but poor scans, unusual fonts, handwriting and complex layouts produce more errors. Always proofread text that matters.
Can OCR read handwriting?
Neat handwriting can be recognised by engines trained for it, often called handwriting or intelligent character recognition. Accuracy is generally lower than for printed text and varies a lot with writing style.
Does OCR change how my PDF looks?
Typically not. Most PDF OCR tools keep the original page image and add an invisible text layer behind it, so the document looks the same but becomes searchable and selectable.

