OCR vs text layer in a PDF
Published 2026-09-10 · FileType Converters engineering
OCR is the process of recognizing characters from images. A PDF text layer is the text objects stored inside the PDF, which may be visible text from a digital export or invisible text placed over a scan. The distinction matters because text-layer extraction is usually cleaner than OCR, while image-only scans need OCR before search or editable conversion can work.
Define the two ideas
OCR is an operation. It examines pixels and predicts characters, words, and sometimes layout. It is needed for scanned paper, screenshots, photos of documents, and fax-like PDFs where the page is an image.
A text layer is content inside the PDF. It may be the visible text generated by Word, InDesign, a browser, or another PDF exporter. It may also be invisible OCR text placed behind or over a scanned page image.
Born-digital text is different
Born-digital PDFs usually preserve characters, fonts, positions, and vector graphics from the source document. Text extraction can often recover words directly. Conversion to DOCX or Markdown still has layout problems, but it starts from actual text rather than guesses from pixels.
OCR text is probabilistic. It can confuse 0 and O, miss punctuation, join columns in the wrong order, or split table cells poorly. Even high-quality OCR should be treated as extracted data that needs review when accuracy matters.
Invisible OCR layers
Searchable scanned PDFs usually keep the page image as the visible layer and add invisible text at matching coordinates. This preserves the original appearance while enabling search and copy. The downside is that copied text can contain OCR errors that are not visible on the page.
Misalignment is common after rotation, deskewing, cropping, or bad OCR. You may click one word and select another. That indicates the hidden text layer no longer matches the visible image closely enough for comfortable use.
How to inspect a PDF
Use pdftotext in.pdf - | wc -w to see whether extractable words exist. Use pdffonts in.pdf to see whether text objects use fonts. A scan with an OCR layer may show fonts for the hidden OCR text; an image-only scan often shows no useful fonts.
Copy a sentence containing numbers, punctuation, and proper nouns. Paste it into a plain text editor. If it contains wrong characters, bad line breaks, or missing columns, the text layer exists but is not reliable for data extraction.
Choosing the right conversion path
For born-digital PDFs, prefer text-layer conversion first. For scanned PDFs, run OCR and then convert. For mixed PDFs, use page-level detection if available and check output page by page.
ocrmypdf --skip-text in.pdf out.pdf adds OCR only to pages that do not already have text. ocrmypdf --force-ocr in.pdf out.pdf rebuilds OCR even where text exists, which can damage good born-digital extraction if used carelessly.
Operational checklist
When quality matters, keep three artifacts: the original PDF, the OCR-searchable PDF, and the extracted text or DOCX. The original preserves evidence, the searchable PDF improves retrieval, and the extracted file supports editing or data review. Collapsing those roles into one file hides tradeoffs.
OCR confidence is not always exposed in a PDF text layer. A page can be searchable while containing low-confidence words. Review critical fields manually and consider retaining per-page OCR logs when the output feeds compliance, finance, or medical records.
A final extraction report should say whether text came from born-digital objects or OCR. That label sets review expectations and prevents users from treating recognized text as if it were the author’s original digital text.
Final checks
For page images from cameras, fix rotation and crop before OCR rather than after. Better geometry improves both recognition and text-layer alignment.
Questions
Is OCR the same as making a PDF searchable?
OCR is the recognition step. Making a PDF searchable usually means storing the OCR result as an invisible text layer in the PDF.
Can a PDF have both images and text?
Yes. Many searchable scans show page images and contain hidden text. Many born-digital PDFs also contain images plus real text.
Why does copied text differ from what I see?
The visible page may be an image while the copied text comes from an OCR layer with recognition errors or alignment problems.