everyday mac tools

What a PDF still hides: layers, attachments, bookmarks and old thumbnails

· 6 min read

A PDF is a container, not a picture of a document. Alongside the pages it can carry attached files, hidden layers, a bookmark tree, thumbnail images of pages as they used to look, form values, annotations and two separate blocks of metadata. None of that appears when you read the file, and all of it travels when you send it.

This post goes through each one: what it is, why it ends up in your file, how to look for it with what macOS already has, and what actually removes it.

Inside the file is a numbered set of objects. Some of them describe pages. Others describe fonts, images, links, attached files, the outline, layer definitions and the document’s own information fields. A viewer reads the catalog at the top, follows it to the pages, and paints those. Everything else is still there; the viewer simply had no reason to draw it.

The other thing worth knowing is that PDFs can be saved incrementally. An edit appends a new version of the changed objects to the end of the file and leaves the old ones in place. That is why “I deleted that page and saved” is not always the same as the page being gone.

Attached files

A PDF can carry other files inside it: the spreadsheet a table came from, an email, a photograph, a second PDF. Document assembly systems, e-filing tools and some export routines do this without announcing it.

Preview gives you no way to see attachments, so on a Mac they are invisible by default. A rough look from Terminal:

grep -a -c EmbeddedFile ~/Desktop/document.pdf

A number above zero means the file references embedded content. Zero is not proof of anything, because much of a PDF’s structure is compressed and will not match a plain text search. Treat a hit as a certainty and a miss as unknown.

Hidden layers

PDFs support optional content: groups of drawing instructions that can be switched on or off. Drawings exported from design and CAD software use them heavily. So do documents with a comments layer, a draft watermark, or several language versions of the same artwork.

A layer that is set to hidden is still in the page’s instruction list. Preview has no layer switcher, so on a Mac a hidden layer is invisible and complete at the same time. The practical test is text: run the whole document through Automator’s Extract PDF Text action and compare the result with what you can see on the pages. Text that comes out of the extraction but appears nowhere on screen is usually sitting in a layer that was turned off.

grep -a -c /OCG ~/Desktop/document.pdf

is the same rough check as above, with the same caveat.

Bookmarks, links and destinations

The outline is a tree of titles pointing at places in the document. In Preview, View, Table of Contents shows it if the file has one.

The titles are written by whoever built the file, which is where the risk sits. “Exhibit C, Smith deposition, unredacted” is a perfectly ordinary bookmark title and a complete disclosure. Link annotations are worth the same look: they can hold a full URL, sometimes with a server path or a query string that names an internal system.

Old thumbnails

A PDF can embed a thumbnail image for each page, generated when the file was written. Preview draws its own thumbnails from the live pages, so you never see the embedded ones.

If a document was edited after those thumbnails were made and the producing software did not regenerate them, the file now contains pictures of the pages as they used to be. They are low resolution, and a low resolution picture of a page before a paragraph was removed is still the paragraph.

Two kinds of metadata

The document information fields come first: title, author, subject, keywords, creator and producer, plus creation and modification dates. Preview shows these in Tools, Show Inspector (Command-I), and Terminal shows what Spotlight read from them:

mdls ~/Desktop/document.pdf

Then there is the XMP packet, an XML block that most producing applications write. It repeats some of the same fields and adds its own, and it can include a history of the tools that touched the document and the names of the files it came from. Preview does not display XMP at all, which means the fields most likely to name a draft are the ones a Mac will not show you.

Form field values and annotation contents belong in the same category. A sticky note, a review comment or the answer typed into a form field is stored outside the page’s text, so Select All and Copy will not bring it back and you can still hand it over.

Looking, with what is already installed

None of these prove absence. They find things.

  1. Preview, Tools, Show Inspector for the document fields.
  2. Preview, View, Table of Contents for the outline, and View, Contact Sheet to skim every page quickly.
  3. mdls in Terminal for what Spotlight indexed.
  4. Automator’s Extract PDF Text action over the whole document, then read the output for anything you did not expect. How to check whether a PDF was really redacted sets that workflow up.
  5. The two grep checks above for attachments and layers.

Removing it

macOS has one blunt instrument that works and costs you something: File, Print, then PDF, Save as PDF. The re-printed file has no bookmarks, no attachments and no layers, and annotations are baked into the page. It also loses the outline you may have wanted, and it does not remove text that was sitting under a black shape, because that text is part of the page and gets printed too. Why a black box on a PDF does not redact anything covers that trap.

For the metadata fields on their own, Remove metadata from a PDF on a Mac has the routes that keep the document intact.

When the container matters as much as the pages, Basalt has a tool called Inspect that reports what a PDF still holds, and a Clean Up tool for layers, bookmarks and attachments. Its redaction exports strip metadata, XMP, attachments, hidden layers and stale thumbnails as part of writing the file.

Questions

Does exporting from Preview strip attachments? File, Export writes a new PDF and generally leaves the extras behind, but Preview does not tell you what it dropped, so it is not something to rely on. Print to PDF is the more predictable version, and you should still check the output.

Can I just delete the pages I do not want to send? Delete them and then export or print to a new file rather than saving over the original. A page removed by an edit that appends to the file can still be in the objects that came before, and splitting is cleaner: Split a PDF into separate files on a Mac covers it.

Is any of this a problem for a document I wrote myself? Often, yes. The producer field names your software and version, the XMP can carry the name of the template or the source document, and a file exported from a shared drafting tool can carry the tracked comments as annotations.

How do I know I got everything? You check the file you are about to send, not the one you were working on, and you check it the way someone else would open it. Absence is hard to prove by reading a document; it is easier to prove by extracting from it and finding nothing.