PDF text layer

The grid of character codes and positions drawn into a PDF page, separate from what the page image shows. No text layer means nothing to extract.

definition

A PDF text layer is the set of font-encoded character-position operators drawn into a PDF page. This data lets you select, search, and extract text on the page, separate from how the page looks.

Also called: text layer, invisible text layer, PDF text layer vs. image

in-plain-terms

Every PDF page renders as pixels on screen. But whether those pixels came with actual characters behind them is a separate question. A born-digital PDF is one made by a word processor, a report generator, or a print-to-PDF step. It writes both the glyph shapes to draw and the character codes and positions that let a reader select and copy text. A scanned page saved as a PDF has only the picture. It has no text layer to read, because none was ever written.

This is why an empty extraction from a PDF usually isn't a bug. If you can't select a word in your PDF viewer, no extraction library can read one either, because there's genuinely nothing there. OCR is the fix when a page has none. See the ocr and searchable-pdf entries below.

example

>>> extracted_text
''

A scanned page has no text layer. Any attempt to extract text from it returns nothing. That is the correct answer, not a parsing failure.

why-it-matters

  • Some documents have a text layer on some pages but not others, like a digital cover sheet ahead of a scanned body. This case fools a whole-document blank check, because the document isn't empty overall.
  • OCR only helps pages that don't already have a text layer. Running it over a page that already has real, selectable text just adds recognition errors where there were none.

how-to-check

  • Try selecting text on the page in any PDF viewer. No highlight means no text layer on that page.
  • Run a file through the PDF text-layer checker. It reports per page instead of per document. Check a PDF's text layer

related-terms

faq

How do I know if a PDF has a text layer?
Try selecting text on the page in any PDF viewer. If nothing highlights, there's no text layer to select, and no extraction library will find one either. The PDF text-layer checker automates this per page rather than per document.
Why did my mixed PDF come back with some text but not all of it?
A digital cover page ahead of a scanned body means the document isn't blank overall. So a whole-document check doesn't flag the scanned pages behind it as missing their own text layer. Check per page, not per document.

related-reading

See the term in real output.

Drop a file into the free reader and watch it happen.

Open the file reader →

Get an API key →