DEV Community

Felix ZHU
Felix ZHU

Posted on Edited on

Removing PDF metadata usually removes one of five copies

Open a PDF from Word, run `exiftool`, and count the places your name appears.
It is rarely one place. That is the thing most "strip metadata" utilities get
wrong: they clear the document information dictionary, the properties panel
goes blank, and the file still carries the original bytes.

## Five carriers, not one

1. **Document information dictionary.** `/Title /Author /Subject /Keywords
 /Creator /Producer /CreationDate /ModDate`. This is the only one most tools
 touch.
2. **XMP metadata.** An XML packet referenced from the catalog via
 `/Metadata`. It repeats much of the same information in a different
 vocabulary (`dc:creator`, `xmp:CreatorTool`, `pdf:Producer`, sometimes
 `xmpMM:History` with every application that ever saved the file).
3. **Page-level `/PieceInfo`.** Illustrator and some layout tools park
 private data here, occasionally including the original layer names.
4. **Attachments and annotations.** `/EmbeddedFiles`, annotation `/Contents`
 and `/T`, form field values.
5. **`Producer` as a fingerprint.** "Microsoft Word 2016" tells a reader
 which machine and which year produced the file, whether or not your name is
 in it.

Setting `doc.setTitle('')` with pdf-lib clears exactly one of these. The XMP
packet is a separate stream and is untouched, so `exiftool` still prints
`xmp:CreatorTool` afterwards.

## The incremental-update trap

PDF is designed to be appended to. When a tool "edits" a file, it often
writes a new revision at the end and leaves the old one intact — that is
how undo works at file level. The obvious consequence: deleting metadata by
appending an update does not delete the old bytes. Run `strings file.pdf`
and the author name is still there, just no longer reachable from the
current revision.

The only honest fix is a full rewrite: create a new document, copy the pages
into it, save. Everything reachable from the old catalog is dropped, and
nothing old remains in the byte stream.

Enter fullscreen mode Exit fullscreen mode


js
const src = await PDFDocument.load(input);
const out = await PDFDocument.create();
const pages = await out.copyPages(src, src.getPageIndices());
pages.forEach((p) => out.addPage(p));
const bytes = await out.save();


That gets you most of the way. It does not remove page-level `/PieceInfo` or
embedded files, which you have to delete explicitly.

## How to verify, in thirty seconds

Enter fullscreen mode Exit fullscreen mode


shell
strings file.pdf | grep -i -E 'author|creator|producer|@'
exiftool file.pdf
pdftotext file.pdf - | head




A clean result looks boring: no personal strings, no `CreatorTool`, `Producer`
either absent or generic, and a file size that dropped noticeably. If the
size barely moved, you almost certainly appended a revision instead of
rewriting.

[Stripping PDF metadata without uploading
anything](https://privacypdf.org/remove-pdf-metadata/) runs this same rebuild
in a browser tab, which is the only way to strip a document you are not
allowed to hand to a third party in the first place.

## The limitation worth stating

Removing metadata is not anonymisation. The content itself still contains
whatever names are in the text, the fonts still reveal the producing
application family, and a scanned page still contains its visible header.
Metadata removal closes one leak, not all of them.

**Update, 21 Nov 2026 — nine compressors, one probe file.** Since this went up I took the same test to the compressing step, because "compressed" is the word most people read as "cleaned". I built a 1.27 MB probe — twelve pages, five marker strings, one planted in each carrier above — ran it through nine browser-based compressors, and read the output bytes back. iLovePDF kept `/Author`, `/Title` and `/Creator`, replacing only `/Producer` with its own name. PDF Candy and PDFgear returned the original `/Producer` string byte for byte. PDF2Go showed an empty Author in the properties panel while `dc:creator` and `xmp:CreatorTool` stayed in the XMP packet. Method, per-tool numbers and the commands to reproduce it: [nine PDF compressors, one probe file, what each one left behind](https://privacypdf.org/pdf-tool-privacy-index/) — my own site, so weigh the framing accordingly.

## Update, 21 November 2026: my first measurement was wrong

I ran a 1.3 MB, 12-page file with five unique marker strings through nine browser tools, then read every output twice — once by scanning raw bytes, once by walking the full object graph with pypdf.

The byte scan flagged three outputs as clean. They were not. Sejda, PDF24 and Xodo had each kept my author name, title and subject; Xodo had stored them inside a compressed object stream (object 26, inside ObjStm 23), which is exactly what a text search cannot reach. PDF Candy went further: it relabelled the visible fields to "PDF Candy" but left the whole original Info dictionary sitting unreferenced at byte 216,924 of a 226 KB file.

Corrected numbers: **7 of 9 tools returned the author name; 4 of 9 kept the original Producer string; only Adobe and Smallpdf left the fields and the XMP packet empty — and Smallpdf still writes its own producer, "Pdftools SDK".**

The lesson is not "all tools are bad". It is that "I checked and it's clean" needs a stated method. Byte search is the weakest of the four ways to look.

If you want to run the same check on a file someone sent you, it now runs in your browser and uploads nothing: [PDF metadata checker](https://privacypdf.org/pdf-metadata-checker/?utm_source=devto&utm_medium=post&utm_campaign=metadata-residue).
Enter fullscreen mode Exit fullscreen mode

Top comments (1)

Collapse
 
parasraju profile image
Paras •

The incremental-update trap really landed for me.