Hidden text in PDFs: what your file isn't showing you
You are not looking at a PDF. You are looking at a rendering of a PDF: the output of a viewer that read the file's internal instructions and decided, obeying the file at every step, what to draw and what to leave out. Layers marked invisible stay invisible. The text layer under a scanned image stays out of sight. Whatever an earlier revision of the file contained is simply not rendered.
That gap between what a file is and what a file shows is where the phrase "hidden text in a PDF" comes from, and it covers more ground than the black-box redaction stories most people have heard. A single file can carry covered-over text, an invisible OCR layer under a picture, entire previous versions of the document, optional content groups, attached files, scripts, and a metadata trail, none of which needs to appear on any page. Here is the tour, then the useful part: how to inspect your own file before someone else does.
Covered is not removed
The most common hidden text is text someone tried to hide with a rectangle. A white-out box or a black bar is just another object in the page's content stream, drawn after the text. It changes what the page looks like and nothing about what the file contains. The letters underneath stay in reading order, selectable and searchable.
This is not a theoretical flaw. In 2018, Paul Manafort's lawyers filed a court document with sections blacked out in a word processor before export, and reporters recovered the supposed secrets by copying and pasting (the BBC's write-up has the details). Three years earlier, the US Army's report on the Calipari shooting went out as a PDF with black boxes, and readers pulled the underlying text out the same way, according to NPR's report. Both files looked perfectly redacted on screen. Neither was.
The fix is a different operation entirely: redaction removes the content objects underneath the mark instead of covering them. If you have already whitened text, that work is not wasted, but it needs to be redone properly; the redaction workflow guide covers the sequence, including the recovery test you run on the output.
The invisible layer under every scanned page
A searchable scan is two documents stacked: a picture of the page, and an invisible text layer produced by OCR, positioned to match the image. Every search, every copy, every screen reader reads the text layer. The image is what your eyes get; the layer is what every tool gets.
Most of the time they agree, and the layer is a pure convenience. The interesting case is when they don't. OCR misreads. A document can be corrected visually after OCR ran, leaving a text layer full of the old, wrong words. Someone can also edit the layer directly, since it is ordinary text content. In both cases the file says one thing to a person and a different thing to Ctrl+F, a copy-paste, or an extraction script. When you extract text from a PDF, you are reading the layer, so a file you are auditing deserves a spot check of the layer against the pixels.
Deleted but still in the file
PDF supports incremental updates: instead of rewriting the file, a tool can append a new revision to the end, leaving every earlier byte in place. Viewers render the newest revision and never mention the others. Forensic tools read them all.
The consequence is uncomfortable. Delete a page, or remove a paragraph, in an editor that saves incrementally, and the deleted content is usually still sitting in the file, parseable by anyone with a script. The same applies to text removed in a revision before the file was signed. A full save that rewrites the document from its current state is what actually discards old revisions, which is why "run it through a full save" is standard advice after any removal job.
Layers, attachments, and scripts
Three more categories that live past the edge of the page:
- Optional content groups ("layers"). PDFs since version 1.5 can group content into layers a viewer shows or hides. Hiding is a display state, not a deletion. The layer's content is fully present in the file, and any tool can flip it on. A layered drawing sent to a contractor with the pricing layer "off" still contains the pricing layer.
- Embedded files. A PDF is also a container: the spec lets a document carry attached files of any type, inside the PDF itself. The PDF Association's explanation of embedded files describes the mechanism. Desktop viewers tend to show a paperclip icon; many browser viewers show nothing at all. Whatever the viewer does, the files travel with the PDF.
- Scripts. The PDF specification includes JavaScript, historically a fruitful exploit vector in desktop readers. Browsers generally ignore PDF scripts, but a file can still carry code you never knew about, and recipients with full desktop readers are the ones who run it.
Metadata, briefly
Alongside all of the above sit the document information dictionary and the XMP block: author, title, timestamps, and very often the creating user's account name and software stack. This territory is deep enough to have its own article on removing metadata from a PDF, so one line here: metadata is the hidden information you can count on finding in every file, not just some.
How to inspect your own file
Four checks, from ten seconds to a minute. (When you find something you'd rather not share, the hidden-information cleanup tool strips it locally.)
1. The copy test. Select everything on a page (Ctrl+A in most viewers), copy, and paste into a plain-text editor. What comes back is exactly what any recipient can extract. Text hidden under a black or white box appears in the paste. Nothing under the box appears if the redaction was done correctly.
2. Ctrl+F. Search for a word you can see, then for words you believe are gone. A hit on a word that is not visibly on the page means an invisible text layer is present. Zero hits anywhere on an obvious scan means there is no text layer yet.
3. pdfinfo or exiftool. pdfinfo file.pdf prints the metadata fields and whether the file is encrypted. exiftool file.pdf goes further, dumping both metadata stores. Either takes seconds and needs no special skill.
4. A sanitize pass. LivePDF's "Remove hidden information…" command opens a checklist of everything it can strip, and the list is a decent inventory of PDF hiding places in its own right: Document metadata (author, title, XMP); Private data of other applications; Scripts; Links and actions that open other files or sites; File attachments; Embedded page thumbnails; Embedded search index; Web capture information; Hidden text (including OCR text layers); Comments and markups; Form fields; Hidden layers; Alternate images; Bookmarks. You choose what to remove and the tool rewrites the file, which as a side effect drops incremental-save remnants. Redaction can chain into it automatically at apply time.
One caveat: the dialog is a removal checklist, not a scan report. It does not claim your file contains each item; it offers to strip each category. The copy test above is what tells you whether the job worked.
The file decides what you see
Every viewer behavior you take for granted (hidden layers off, annotations collapsed, no attachments panel open) is a decision the file made on your behalf, and your viewer executed without asking. The same thing happens to your recipient. Nobody in the exchange is seeing the document; everyone is seeing the document's preferred presentation of itself.
So don't audit a file by staring at it. Staring at a rendering is how the Manafort filing stayed "redacted" for a full news cycle. Audit the data: run the copy test, check the metadata, and if the file must leave clean, remove the hidden information and then try to get the content back out of the result. If your copy attempt fails, so will everyone else's. Encryption can also limit who gets that far, though it does not remove anything from inside the file, which is the distinction covered in is my PDF encrypted.
A PDF is not a page. It is an archive that agrees to show you one page at a time, and the rest of the archive goes wherever the file goes.
FAQ
How do I find hidden text in a PDF?
Select everything on the page and paste it into a plain-text editor, then search for words that are not visibly on the page. Anything that comes back this way, whether text under a black box or an invisible OCR layer, exists in the file no matter what the page looks like.
Does flattening a PDF remove hidden information?
No. Flattening merges annotations and layers into the page's drawing instructions, but the underlying text and metadata usually survive it. A full rewrite by a save-as or sanitize operation is what drops leftover revisions and optional data.
Is a scanned PDF with OCR safe to share?
Treat the OCR text layer as part of the document, because search and copy read the layer, not the image. If the scan was corrected after OCR ran, or the OCR misread something, the layer can differ from what the page visibly says. Re-run OCR or verify the layer before sharing.