PDF ExplainedApril 2, 20264 min read

What Is a Sandwich PDF? OCR Text Layer Explained

A sandwich PDF has a visible image layer and an invisible OCR text layer "sandwiched" together — combining the visual fidelity of a scan with the searchability of text.

A sandwich PDF — also called a "searchable image PDF" — has two layers stacked on every page: a visible raster image (the scan) on the bottom, and an invisible text layer on top. The text layer contains the OCR-recognized characters positioned exactly over their corresponding scan positions. Users see the original scan; search and copy operations use the invisible text layer. It's the universal output format of PDF OCR tools.

Why the Sandwich Structure

The sandwich structure solves a fundamental problem: users need documents to look exactly like the original (for legal validity, readability of handwriting, and preservation of original formatting) while also needing the document to be searchable and copy-paste-able. Replacing the scan with plain text would lose the visual fidelity. The sandwich gives both: the image preserves the visual appearance exactly; the text layer provides functionality. Courts and archives accept sandwich PDFs as authentic reproductions of original documents precisely because the visual layer is unmodified.

How the Text Layer Is Structured

In a sandwich PDF, each page's content stream contains: (1) the page image as a full-page XObject rendered at the page size, (2) text rendering mode 3 (invisible text — zero fill and stroke width) with text positioning operators placing recognized characters at their computed positions. The characters are positioned to overlay their visual counterparts as precisely as the OCR engine could determine. Highlighting text in a viewer activates the text layer, and the viewer draws highlights over the image at the positions of the selected characters.

Quality Indicators

The quality of a sandwich PDF depends on: OCR accuracy (how correctly characters were recognized), positioning accuracy (how precisely characters are placed over their image counterparts), and character encoding (whether Unicode mappings are correct so searches work across different encodings). A high-quality sandwich PDF has text selections that visually align with the underlying scan text. A low-quality one has text that appears misaligned when selected — often a sign of inaccurate page rotation correction or low-resolution source.

Alternative: Native Text PDF

Some OCR tools produce a "native text" PDF — replacing the image entirely with actual rendered text. This looks clean and is fully text-based, but loses the original scan appearance. For legal documents, medical records, and archival use, native text PDFs may be unacceptable because they no longer represent the original document. For general usability where visual fidelity to the original is unimportant, native text PDFs are smaller and more accessible.

Try PDF to Text Now — Free

Browser-based, private, and instant. No account or software required.

Open PDF to Text
Report Bug
Send Feedback
Feature Request