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 prope
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.
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
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.
📰 Read the original article on Dev.to Security
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.