Scanned or searchable? How to tell if a PDF has real text

Updated · Tested with PyMuPDF 2.2, Poppler 25.03, OCRmyPDF 17.14

In short

A searchable PDF stores letters; a scanned PDF stores a picture of each page. If you cannot select a word in a viewer, it is a scan. In code, a page whose extracted text is empty and which contains an image is a scan. OCR turns a scan into a searchable PDF by adding an invisible text layer.

Two PDFs can look identical on screen and be completely different inside. One holds text; the other holds a photograph of text. Everything you want to do with a document, searching it, copying from it, extracting data, depends on which one you have.

QuestionSearchable (text) PDFScanned PDF
Made byExporting or printing from a programA scanner or a camera
Inside the fileLetters, fonts and positionsOne picture per page
Select and searchYesNo
Size of one pageA few kilobytesOften 100 kilobytes or more
To get the textRead it from the fileOCR

A third kind is a scan that has been through OCR: the picture is still there, and an invisible layer of text sits on top of it. It behaves like a searchable PDF, and its text is only as good as the OCR was.

Check by hand

Open the file and try to select a single word. If the cursor draws a box across the page instead of highlighting words, it is a scan.

Check in code

A page with no text and at least one image is a scan. With PyMuPDF:

Python
import pymupdf

def page_kinds(path):
    kinds = []
    with pymupdf.open(path) as doc:
        for page in doc:
            if page.get_text().strip():
                kinds.append("text")
            elif page.get_images():
                kinds.append("scan")
            else:
                kinds.append("empty")
    return kinds

for name in ["company-extract.pdf", "company-scan.pdf", "mixed-text-and-scan.pdf"]:
    print(name, page_kinds(name))
Output
company-extract.pdf ['text']
company-scan.pdf ['scan']
mixed-text-and-scan.pdf ['text', 'scan']

Check every page, not the first one. The third sample, mixed-text-and-scan.pdf, has a text page followed by a scanned one, which is common when a signed page is scanned and added to an exported document.

Check from the command line

The Poppler tools answer the same question. pdffonts lists the fonts in a file; a scan has none:

Shell
pdffonts company-scan.pdf
Output
name                                 type              encoding         emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------

For company-extract.pdf the same command lists two fonts. And pdfimages -list shows the picture a scan is made of, with its resolution:

Shell
pdfimages -list company-scan.pdf
Output
page   num  type   width height color comp bpc  enc interp  object ID x-ppi y-ppi size ratio
   1     0 image    2481  3508  rgb     3   8  image  no         7  0   300   300  169K 0.7%

One image the size of the whole page, at 300 dots per inch: a scan.

Make a scan searchable

OCRmyPDF adds a text layer to a scanned PDF and leaves the picture as it is. It uses the Tesseract OCR engine underneath.

Shell
ocrmypdf company-scan.pdf searchable.pdf

Afterwards the check above reports ['text'], and pypdf reads the new file:

Output
COMPANY EXTRACT
Company name Harbor Lane Logistics Ltd

Three options cover most real files:

OptionWhen
--skip-textMixed files: OCR the scanned pages, leave pages that already have text
--force-ocrThe file has text, but it is wrong or gibberish
-l heb+engThe document is not in English; name its languages

Without one of the first two, OCRmyPDF stops when it finds a page that already has text. That protects good text from being replaced by a worse reading.

Why it matters for extraction

  • Cost and speed. Reading text from a file takes milliseconds. OCR takes around a second a page and more memory. Send only the pages that need it.
  • Accuracy. Text read from the file is exact. OCR makes mistakes, more of them on poor scans; see how to improve OCR accuracy.
  • Positions. Positions in a text PDF are exact, and positions from OCR are approximate.

How 100sands handles the two kinds

100sands reads only the first kind: PDFs and HTML files that contain text. It does not do OCR.

A PDF with no text on any page, such as company-scan.pdf, is refused with status 422 and a body of this shape:

JSON
{
  "error": "NO_TEXT_IN_FILE",
  "message": "This PDF has no text in it. It is probably a scan or a photo; only PDFs with text can be read."
}

A file that mixes the two, like mixed-text-and-scan.pdf, is read. The text page comes back, and the scanned page comes back blank, with no error. The response has this shape:

JSON
{
  "pages": 2,
  "text": "COMPANY EXTRACT\nCompany name\tHarbor Lane Logistics Ltd\n...\f"
}

Pages are separated by a form feed (\f), and nothing follows the one after the first page. If a blank page would matter to you, check your files page by page with the code above before you send them.

Questions

How can I tell if a PDF is scanned?

Try to select a word. In a scan you cannot, because the page is one picture. In code, extract the text of each page: a page with no text and at least one image is a scan.

What is a searchable PDF?

A PDF that contains text you can select, search and copy. It is either exported from a program or a scan to which OCR has added an invisible text layer over the picture.

How do I make a scanned PDF searchable?

Run OCR on it. The free OCRmyPDF tool does it in one command, ocrmypdf scan.pdf searchable.pdf, keeping the page pictures and adding the text behind them.

Can one PDF be both scanned and searchable?

Yes. Files often mix exported pages with scanned ones, such as a signed last page. Check every page, and use ocrmypdf --skip-text to OCR only the pages that need it.

Try it on your own documents

A free plan every month, no credit card. See the PDF to text API.

Start free