A PDF can carry text that is stored in the file but drawn invisibly, for example an OCR layer under a scanned image or white text on a white background. That hidden text shows up in search results and in copied text, so a search can match words no reader can see on the page.
What you need
- pdftotext installed
- A PDF you suspect carries hidden text
- A text editor to search the extracted output
Step 1: Extract the full text
Run pdftotext file.pdf out.txt and open the output. Search it for a word you do not remember seeing on the page.
Step 2: Compare with the visible page
Open the page in a PDF reader and search the same word there. If the extractor finds it but the reader does not highlight it on the page, the text is hidden.
Step 3: Decide whether to strip the layer
For an OCR layer you no longer trust, use OCRmyPDF with –mode strip to remove the invisible text layer, then re-extract and confirm the hidden words are gone.
Worked example: synthetic hidden-text check on a scanned memo
The table below is a synthetic example. It shows the expected result of comparing extracted and visible text; no extraction was run.
| Word in extracted text | Visible on page? | Verdict |
|---|---|---|
| Quarterly results | Yes | Normal text |
| Confidential draft | No | Hidden text – check source |
| Meeting notes | Yes | Normal text |
| Old project name | No | Hidden text – stale OCR layer |
Expected result (UNTESTED). 2 of 4 checked words appear in the extracted text but not on the visible page, so the file carries a stale hidden text layer. Strip it with OCRmyPDF –mode strip before the file is shared or indexed. This check was not run live; the table shows the expected result for the synthetic example.
Limits
- OCRmyPDF –mode strip removes only text drawn as invisible; text drawn in the page colour is visible text and is left in place.
- A hidden layer can be intentional, for example an OCR layer under a scan, so check why it is there before removing it.
- Re-extract after stripping to confirm the layer is actually gone.
