Dashboard

What Is OCR? How Text Is Read From Images and PDFs

OCR converts text in a photo or scan into real, editable text. Here are the two modes, the five checks before you trust the output, and when an AI model is the better tool.

Cecilia Iona
Cecilia Iona
Senior Editor, AI & Product
21 October 20261 min read

OCR, short for optical character recognition, is software that reads the letters in a picture and turns them into real text you can search, copy and edit. A scan of a receipt is just pixels until OCR converts it. Google's Cloud Vision documentation describes its text detection feature as "optical character recognition (OCR) for an image," which converts the text into machine-coded text. If you are building anything that handles invoices, forms, receipts or screenshots, OCR is likely part of the pipeline whether you chose it or not.

What OCR does, step by step

OCR works in two stages. First it finds where text sits in the image. Then it works out which character each patch of pixels represents. Good systems return more than a string. The Vision API returns the full extracted text, the individual words, and a bounding box for each, so your app knows where on the page each word was.

That position data is useful. It lets you pick out the total at the bottom right of a receipt, rather than only knowing the word "total" appeared somewhere.

Two modes: photo text and document text

The same Google service offers two separate OCR features, and the difference is a good guide to how to choose.

  • Text detection "detects and extracts text from any image," such as a street sign in a photo. Use it for short, scattered text in a natural scene.

  • Document text detection is "optimized for dense text and documents." It returns a layered breakdown down to page, block, paragraph and word levels, which helps with multi-column pages and long documents, and the feature list says it also covers handwriting.

Using the wrong mode is a common cause of poor results. Feed a dense contract into the photo mode and the text may come back in a jumbled order. The Cloud Vision OCR documentation describes both.

Where OCR goes wrong

OCR rarely fails loudly. It returns confident text that is subtly wrong. These five checks catch the usual problems:

  1. Digits that look alike. Zero and the letter O, or one and lowercase L, are easy to swap. Always check numbers, especially amounts and dates.

  2. Column order. On a page with two columns, text can be read straight across both, producing sentences that mix the columns.

  3. Tables. Cell borders are not text, so table rows can collapse into a single line. Check totals against the source.

  4. Image quality. Blur, shadows, a skewed photo or low resolution all reduce accuracy. Retaking the photo often beats tuning the software.

  5. Handwriting and stylised fonts. These have a much higher error rate. Treat output as a draft.

A cheap safeguard: have the app show the original image next to the extracted text for anything where a mistake costs money.

OCR or an AI model?

Modern AI models can look at an image directly and answer questions about it, which raises a fair question about whether you need OCR at all. The honest answer is that they do different jobs. What a vision-language model is explains the model side.

You need

Better fit

Every word from a long document, exactly as written

OCR, then check

Word positions to highlight or crop

OCR, because it returns boxes

To understand a document, such as "what is the due date?"

An AI model, often fed OCR text

A cheap, repeatable job over thousands of pages

OCR first, model only on hard cases

A messy photo of a handwritten note

Try an AI model, then verify by eye

In many real systems the two run together: OCR extracts the text, and a model interprets it. How to choose an AI model for document extraction compares options for that second step.

Using OCR safely with AI

Text pulled from an image is still untrusted input. If a scanned page contains an instruction aimed at your AI model, the model may follow it. Prompt injection through an image shows how that works. For the prompting side, see how to prompt AI to read a scanned document and how to prompt AI to extract data from a document.

FAQ

What does OCR stand for?

Optical character recognition. It means recognising written characters in an image.

Is OCR the same as AI?

OCR is a form of computer vision and often uses machine learning, but it does one narrow job. General AI models can do more with an image and are less predictable.

How accurate is OCR?

It depends on image quality, fonts and layout. Clean printed text does far better than blurry photos or handwriting, so verify anything important.

Can OCR read handwriting?

Some services support it, including Google's document text detection. Results vary widely, so check the output.

Can OCR read a PDF?

Yes, when the PDF is a scan or an image. If the PDF already contains real text, you can extract it directly without OCR.

How did this land?

About the author

Cecilia Iona
Cecilia Iona

Senior Editor, AI & Product

Cecilia leads the Swarmz editorial desk. She has spent a decade turning complex AI and product topics into writing people actually finish, and she owns the blog's quality bar.

Share

Get the next post in your inbox

One email a month. Product updates, engineering posts, and the best of Built with Swarmz.

I agree to receive emails about AI building tips and Swarmz product news. Unsubscribe any time.