Guide
Scanned PDFs and screen readers: why OCR is step one
Signed minutes, old bylaws, forms filled in by hand: many PDFs on public websites started life on a scanner. To a screen reader, a scanned page is a picture with nothing to read. Text recognition (OCR) is the first step to fixing that, and it is not the last.
Why a scan has nothing to read
When a PDF is made from a word processor, the file holds the actual characters: a screen reader can read them aloud, and you can search, copy and enlarge the text. When a page is scanned, the file holds a photograph of the page. The words are visible to a sighted reader, but there are no characters inside the file, only pixels.
A screen reader opening such a page finds nothing, or announces only that there is an image. The W3C describes a document made of scanned text images as inherently inaccessible, because assistive technology cannot get at the words and users cannot select or resize them.
WCAG, the guidelines that the laws on our deadlines page refer to, addresses this in two places:
- 1.1.1 Non-text Content (Level A): all non-text content presented to the user has a text alternative that serves the equivalent purpose. An image of words counts as non-text content.
- 1.4.5 Images of Text (Level AA): if the technology can present the text as real text, use real text instead of an image of it, with exceptions for images that can be customised and for cases where a particular presentation is essential, such as a logo.
How to tell if a PDF is a scan
- Try to select the text. Open the PDF and drag across a sentence. If the whole page highlights as one block, or nothing highlights, the page is probably an image.
- Search for a word you can see. If your PDF reader's search finds nothing, the text is not there as characters.
- Look closely. Slightly crooked lines, a grey background, specks, handwriting or a stamp are signs of a scan.
- Use the free quick check on our home page. Its "pages with no text" item lists every page where it finds no text characters, and notes when such a page holds images, which usually means a scan.
Some PDFs mix the two: a typed report with a scanned signature page at the end, or a scan that already has OCR text from the scanner. Check every page, not only the first. The guide to checking a PDF covers the other basics to look for at the same time.
Step one: OCR
Optical character recognition looks at the picture of each page and works out the characters. Tools such as OCRmyPDF then place the recognised text as an invisible layer behind the image, so the page looks the same but now contains real text. The W3C's technique PDF7, "Performing OCR on a scanned PDF document to provide actual text", describes exactly this as a sufficient way to meet the images-of-text criterion.
Free tools can do it. Tesseract is an open-source OCR engine that recognises more than 100 languages. OCRmyPDF is a free, open-source command-line program that uses Tesseract to add an OCR text layer to scanned PDFs so they can be searched and copied. Paid PDF editors, including Adobe Acrobat Pro, also have OCR built in.
If you still have the original typed document, there is a better route than OCR: make the PDF again from the source file, with accessibility settings turned on.
OCR makes mistakes, so check it
OCR reads print well and struggles with faint copies, small type, stamps, handwriting, tables and columns. A "1" can become an "l", a dollar amount can lose a digit, two columns can merge into one line. A screen reader user hears the errors and cannot see the page to correct them.
The PDF Association's Matterhorn Protocol lists OCR text with character recognition errors as a failure that needs human judgment: a checker cannot decide it. The W3C's test for PDF7 suggests listening to the document with a screen reader, or saving it as text, and checking that the text is complete and in the right reading order. For important numbers, such as fees, dates and vote counts, compare against the image by eye.
Step two: structure
OCR gives you text, not structure. After OCR the page still needs what any accessible PDF needs: tags for headings, paragraphs, lists and tables, a reading order, alternative text for photos, signatures or stamps that carry meaning, a document title and a language. The untagged PDF guide explains tags, and PDF/UA and veraPDF explains how the result is checked. Scans often sit in the higher price tiers for this reason; see PDF remediation cost.
Sources
- W3C: Understanding Success Criterion 1.1.1 Non-text Content
- W3C: Understanding Success Criterion 1.4.5 Images of Text
- W3C: PDF7, Performing OCR on a scanned PDF document to provide actual text
- PDFlib knowledge base: Matterhorn Protocol (OCR errors need human judgment)
- Tesseract OCR on GitHub
- OCRmyPDF on GitHub
Find the scanned pages
The free quick check reads a PDF in your browser, without uploading it, and lists the pages with no text. Pagorin's Starter plan, US$79 a month for 100 pages, adds an OCR text layer to scanned pages, tags the result, checks it with veraPDF and lists what a person should confirm.