Schema LawSign in with Google

OCR for PDF Documents: Which Files Need It, Which Do Not

By Schema LawPublished Updated

PDF documents need OCR when their pages are pictures: scans, faxes and photos saved as PDF. PDF documents saved from a word processor or another program already hold their text and do not. Many files mix the two, so the choice is made page by page, and a ten-second test on a few pages settles it.

Running recognition on everything is a common shortcut, and it is not harmless. On the wrong file it swaps exact text for a guess. The sections below sort the cases, including files that are half typed and files that already carry text from an earlier pass.

Which PDF documents need OCR and which already have text?

A PDF document needs OCR if you cannot select a word on its pages. It already has text if words highlight one at a time and a search finds them. Scanned documents fall in the first group, and files exported from software fall in the second. A third group has text of doubtful quality.

GroupExamplesNeeds OCR?
Pictures onlyCopier scans, faxes, phone photos saved as PDF, records copied from paperYes
Text written by softwareA brief saved from a word processor, a downloaded bank statement, an e-signed agreementNo
Pictures with text from an earlier passA scan the copier "made searchable", a production that arrived with a text layerDepends on how good that text is

Why the first two groups differ is covered in the post on native PDF versus scanned PDF. If you want a fuller way to test a page than dragging the cursor across it, the post on why you cannot copy text from a PDF describes how to tell whether a PDF has real text.

Two points keep the sorting honest.

  • The file name and the sender tell you nothing. A file called Lease_final.pdf from a law firm can be a scan of a printout.
  • The first page tells you about the first page. Test one page near the start, one in the middle and one near the end before you put a file in a group.

The third group is where judgment comes in, and two of the later sections deal with it.

PDF documents that are part typed and part scanned

A PDF document can hold typed pages and scanned pages in the same file, and each page keeps its own nature. The typed pages have exact text and need nothing. The scanned pages need OCR. The aim with a mixed file is to recognize only the pictures and leave the rest alone.

Mixed files are normal in legal work, because documents are assembled from parts.

  • A motion saved from a word processor, followed by scanned exhibits.
  • A closing binder with drafted agreements, scanned signature pages and a recorded deed.
  • A contract in which only the signature page was printed, signed and scanned back in.
  • A records request response with a typed cover letter in front of copied charts.

A worked example

Suppose you receive a 62-page opposition brief in a matter between two fictional parties, Ostrander Farms and Vell Logistics.

PagesContentKindAction
1 to 18BriefTypedLeave as it is
19 to 44Exhibit A, a scanned supply contractPicturesRecognize
45 to 58Exhibit B, emails printed to PDFTypedLeave as it is
59 to 60Exhibit C, a handwritten delivery logPicturesRecognize, and expect a weak result
61 to 62Certificate of serviceTypedLeave as it is

A search for "Vell" in the file as received finds the brief and the emails and silently skips the contract. That is the usual symptom of a mixed file: hits cluster in some page ranges and stop dead in others.

Once the folder is sorted, search one exhibit for the party names and one pleading for the allegation you need as proof. The brief may already hold typed words while the exhibit is only a picture. Run recognition on the exhibit. Sending the pleading through the same pass can replace a clean allegation with a guess.

Pages that are mixed within themselves

Mixing also happens inside one page.

  • A typed page with a pasted picture. The paragraphs search. The screenshot of a spreadsheet in the middle does not.
  • A scanned page with a typed stamp. An e-filing header, a Bates number or a footer was added later as real text. The page "has text", and a tool that checks for text will pass it, yet the body is still a picture.

The second case fools both people and software. If the only word you can select on a page is in its header or footer, treat the page as unrecognized.

Should you run OCR on a PDF that already has a text layer?

Run OCR again only when the existing text layer came from an earlier recognition pass and is poor. If the text was written by the authoring program, leave it. If an earlier pass did a good job, leave it. Work out where the layer came from and how good it is before you replace it.

The existing text isHow you can tellRun OCR again?
From the authoring programSharp type at high zoom; pasted text is exactNo
From an earlier pass, and goodScanned look; pasted text reads correctlyNo
From an earlier pass, and poorScanned look; pasted text has wrong letters or missing linesYes, on a copy
Only a stamp, header or page numberBody words will not selectYes
UnknownYou have not lookedTest three pages first

Judging an existing layer in two minutes

  1. Pick three pages: an ordinary one, the worst-looking one, and one with numbers.
  2. On each, select all, copy, and paste into a blank document.
  3. Read the pasted text against the page. Count wrong names and wrong figures.
  4. If the ordinary page is clean and the worst page is usable, keep the layer.

Text added by the scanner at the moment of scanning deserves particular suspicion, since a copier's settings were chosen for speed and by someone else. The post on the OCR text scanner explains what happens when a device both scans and recognizes, as opposed to scanning first and recognizing later.

What tools do when they find text

Tools differ in how they treat a page that already has text, and you should know your tool's behavior before pointing it at a folder. The open-source OCRmyPDF is a clear illustration because its documentation spells out each option. Its guide to advanced features says that when a page seems to have text, "by default OCRmyPDF will exit without modifying the PDF." With its skip option, "no image processing or OCR will be performed on pages that already have text." A third option forces recognition of every page.

Other products make other choices, and some never tell you which. Test with a mixed file.

When OCR makes a PDF document worse

OCR makes a PDF document worse when it replaces text that was exact with text that was recognized. Forcing recognition onto typed pages turns each page into a picture, reads the picture, and stores the reading. You end with a larger, softer file whose words are now estimates.

The OCRmyPDF documentation describes its force mode in exactly those terms: "all pages will be rasterized to images, discarding any hidden OCR text, rasterizing any printable text, and flattening form fields or interactive objects into their visual representation." The option exists for good reasons, such as replacing a bad layer. Applied to a file of typed pages, it destroys what made them valuable.

Before forced OCRAfter
Exact characters from the authoring programA reading of a picture of those characters
Type that stays sharp at any zoomPixels at a fixed resolution
A small fileA file several times larger
Fillable form fieldsFields flattened into the picture
A digital signature that validatesA changed file, so the signature no longer validates
Structure for screen readersUsually gone

How it happens in practice

A paralegal at a fictional firm receives 300 PDFs and is told to "OCR the lot" before loading them into a review tool. Two hundred are typed documents. The batch job is set to process every page so nothing is missed. The next week, a search for the account number 4471-0092-88 misses a typed bank letter in which it plainly appears, because the recognized version reads 4471-0O92-88. The original file would have matched.

Other ways recognition does damage

  • Two layers at once. A new layer is added on top of an old one, and searches return double or conflicting hits.
  • Aggressive cleanup. A tool "improves" the page picture by removing specks, and takes decimal points or faint stamps with them.
  • Heavy compression. The output is smaller because the pictures were squeezed, and small print is now harder to read by eye.

The safeguards are simple. Keep the file as received. Run recognition on a copy. Sort before you process, so typed files never enter the batch.

Sorting a folder of PDF documents by whether they need OCR

Sort a folder by testing a few pages of each file and assigning it to one of five bins: leave alone, recognize all, recognize some pages, recognize again, or set aside. Twenty minutes of sorting saves you from both failures, the scan nobody recognized and the typed file somebody damaged.

What you find when you testBinWhat to do
Words select on every tested page; type is sharpLeave aloneNothing. Use the text as it is
No word selects on any tested pageRecognize allRun OCR on a copy
Words select on some pages and not othersRecognize someUse a tool that skips pages with text, or split out the scanned ranges
Scanned look; words select; pasted text is cleanLeave aloneNote that the text is recognized, not typed
Scanned look; words select; pasted text is garbledRecognize againReplace the layer, on a copy
Only headers, footers or stamps selectRecognize allCheck afterwards for duplicate header text
File will not open, or asks for a passwordSet asideGo back to the sender

A procedure for a large folder

  1. Copy the folder. Work only in the copy.
  2. Sort by file size. Among files of similar page count, the large ones are usually scans and the small ones usually typed.
  3. Test three pages of each file and write down its bin.
  4. Process the "recognize" bins. Leave the rest untouched.
  5. Re-test one page from each processed file.

Keep the notes. A plain log is enough:

File                      Pages  Bin              Tested   Notes
Ostrander_Opp_Brief.pdf   62     Recognize some   1,30,60  Exh A and C scanned
Vell_Statement_0321.pdf   4      Leave alone      1,2,4    Portal download
Delivery_Log_2021.pdf     11     Recognize all    1,6,11   Handwritten; weak

Check the sizes against your tool while you sort. Schema Law accepts files up to 20 MB, and each plan caps the pages in one document: 3 on the free plan, 250 on Solo and 1,000 on Team. The pricing page has the monthly page allowances.

What does an OCR tool for PDF change in the file it returns?

An OCR tool for PDF always changes one thing in the file it returns: it adds recognized text. Beyond that, tools vary. Some leave the pictures exactly as they were. Others straighten, clean, recompress or redraw pages, and rewrite the document properties. Find out which kind you are using.

Part of the fileAlways changedSometimes changedShould not change
Text layerAdded or replaced
File size and hash valueYes
Page picturesStraightened, cleaned, recompressed or redrawn
Page size and rotationRotated upright; resized to a standard sheet
Document propertiesProducer and modified date rewritten
Bookmarks, links, form fieldsDropped or flattened by some tools
The words on the visible pageWhat a reader sees should say the same thing

The file's hash value changes whenever anything in the file changes, so a recognized copy never matches the hash of the original. If hash values matter in your matter, they belong to the file as received.

Tools that return a new file instead

Not every OCR tool for PDF edits your PDF. Some read it and hand back separate exports, leaving the upload as it was. Schema Law works that way: you upload once and export in as many of the eight formats as you need. Its searchable PDF is described on the homepage's export formats section as "Your original file with a hidden text layer", and the Word, text and data exports are new files built from the parsed pages.

A before-and-after check

Whatever you use, compare the returned file with the one you sent.

  • Same number of pages, in the same order.
  • Same page orientation, unless you wanted sideways pages turned.
  • A stamp or signature looks identical at 200% in both.
  • Bookmarks and links, if there were any, still work.
  • A word you can see on a late page is now found by search.

Run that check on the first file of any batch, and again whenever you change a setting. It takes less time than explaining later why an exhibit looks different from the copy the other side has.

All posts in OCR basics