Tools,

PDF not searchable? Find the cause first

16 of 16

test PDFs diagnosed right

Get why-not-searchable.py

One command names the cause

A PDF can look like text and hold none. why-not-searchable.py checks each page with the free Poppler tools, then prints the cause and one fix.

why-not-searchable.py

brew install poppler ocrmypdf
python3 why-not-searchable.py letter.pdf

On our test letter, page 2 was a scan:

page 1: searchable text
page 2: scanned page: a page-size picture and no text layer
fix: ocrmypdf --skip-text 'letter.pdf' searchable.pdf

It only reads the file, and nothing leaves your computer. MIT license.

6 causes that OCR fixes

Words a search finds, of 300, in a made-up 2-page letter
Cause and fix Before After
Scanned pageocrmypdf 0 300
Text drawn as shapesocrmypdf 0 300
Broken font mapocrmypdf --force-ocr 1 300
Some pages scannedocrmypdf --skip-text 151 300
Picture of text on a text pageocrmypdf --redo-ocr 260 300
Old OCR layer on a tilted scanstraighten.py, then ocrmypdf 8 to 138 300

Each file came in Times New Roman and Arial. Both fonts gave the same numbers, except the tilted layer.

The wrong flag fails quietly

Tilted scan? Straighten it first

Our tilted letter was 6.5 degrees off. In our deskew test, --deskew gave up past about 5 degrees. Here it did nothing.

straighten.py from that guide turned each page back and made a new PDF without the old layer. Then OCRmyPDF found 300 of 300 words.

python3 straighten.py tilted.pdf straight.pdf
ocrmypdf --rotate-pages --deskew straight.pdf searchable.pdf

Copying turned off? Ask the author

Some PDFs have a lock that turns copying off. pdfinfo shows copy:no, and the script says so. Ask the author for a copy without the lock.

Our Actor read 4 of the 6 causes

Our Apify Actor turns PDFs into text or Markdown. It found 299 or 300 words in the scans, the shapes, the mixed files and the tilted layer.

It kept the junk of the broken map (1 to 4 words) and missed the words in the screenshot (260). For those two, use the script first.

A scanned page costs $0.006, and pages with a text layer are free.

Try the Actor

How I tested it
  • A 2-page letter I wrote, 300 words, made-up names. fpdf2 set it in Times New Roman and Arial, fonts embedded.
  • Scan: drawn at 300 dpi, blurred, tilted under 0.6 degrees, with noise, saved as JPEG. Renders, not real scans.
  • Shapes: pdftocairo to SVG and back with rsvg-convert. Broken map: every ToUnicode map deleted.
  • Copy off: pikepdf, AES-256, copying turned off. I did not try to read around the lock.
  • Mixed: text page 1, scanned page 2. Picture: one paragraph as a screenshot. Tilted layer: the scan at 6.5 degrees, then plain OCRmyPDF.
  • Words: pdftotext against the true text, any case, counted per use. OCRmyPDF 17.13.0, Tesseract 5.5.4, Poppler 26.03.0.
  • OCRmyPDF took 1.0 to 6.1 s a file, with 2 jobs at low priority.
  • The Actor's code at build 0.1.97 read the files on our Mac, with 4 of its 18 word lists. English is one of them.
  • Not tested: real scans, other languages, Ghostscript outlines, paid tools.

Questions people ask

Why is my PDF not searchable?

Most often a page is a scan: a picture with no text. Text drawn as shapes, a broken font map and an old OCR layer do it too. why-not-searchable.py tells you which.

Why can't I select text in a PDF?

There is no text to select: the page is a picture or shapes. OCR adds a text layer. If the author turned copying off, ask the author for an open copy.

Why does Ctrl+F not work in my PDF?

Ctrl+F finds only the text layer, not the picture. In our test, the command the script printed brought 10 of 12 broken files back to all 300 words.