You export a contract, a proposal or a résumé to PDF, attach it to an email and move on. The file has a visible page count and a file name. It also has a title, an author, the application that made it, the exact second it was created and the exact second it was last saved. None of that shows on the page.

This post covers where that data lives inside a PDF, why clearing one field is not the same as removing it, and a short Node.js routine that I tested against a sample file with identifying metadata.

What metadata does a PDF actually store?

A PDF keeps document-level metadata in two separate places.

  1. The Info dictionary. This is the older mechanism and the one most tools show. The keys that ExifTool reads and writes are Title, Author, Subject, Keywords, Creator, Producer, CreationDate and ModDate (ExifTool PDF tag reference). Creator is usually the authoring application (for example a word processor) and Producer is the library that wrote the PDF.
  2. An XMP stream. The document catalog can point to an XML metadata stream. It often repeats the same facts as the Info dictionary and can add more, such as the author list and the tool history. ExifTool lists it as the Metadata entry in the catalog.

A short answer to "does deleting the author in my PDF viewer remove it?": it removes it from the place the viewer edited. If the same name is also in the XMP stream, or in an earlier revision still sitting in the file, it can survive.

That second case is the one that catches people, so it is worth looking at how files get edited.

Why does "clearing the field" often leave data behind?

There are three common failure modes.

The XMP stream is left alone. Many libraries expose setters for the Info dictionary only. You blank the author there and the XMP copy stays.

The old object is still in the file. If you drop the reference to the XMP stream but save the same document, the stream can still be written out as an unreferenced object. A text search for the author's name still finds it.

The edit is an incremental update. ExifTool writes metadata changes by appending to the file. Its documentation says this technique is fast and reversible, and then spells out the consequence: "All metadata edits are reversible", and old information is never actually deleted from the file. The documented way to remove it permanently is to rewrite the file with qpdf: qpdf --linearize in.pdf out.pdf. So after using ExifTool to blank a field, you still need a rewrite step if the old value matters.

Let's reproduce it with pdf-lib

pdf-lib is a pure JavaScript library for creating and modifying PDFs. It works in Node and in the browser, which matters if you do not want to upload a sensitive file anywhere.

First, build a sample file with identifying metadata and an XMP stream:

import { PDFDocument, PDFName } from 'pdf-lib'; import fs from 'node:fs'; const src = await PDFDocument.create(); src.addPage([300, 200]).drawText('Q3 draft'); src.setTitle('Q3 acquisition plan'); src.setAuthor('Jane Doe'); src.setCreator('Word'); src.setProducer('Microsoft Word 16'); src.setKeywords(['confidential', 'acme']); const xmp = `<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?> <x:xmpmeta xmlns:x="adobe:ns:meta/"><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <rdf:Description xmlns:dc="http://purl.org/dc/elements/1.1/"> <dc:creator><rdf:Seq><rdf:li>Jane Doe</rdf:li></rdf:Seq></dc:creator> </rdf:Description></rdf:RDF></x:xmpmeta><?xpacket end="w"?>`; const stream = src.context.stream(xmp, { Type: 'Metadata', Subtype: 'XML' }); src.catalog.set(PDFName.of('Metadata'), src.context.register(stream)); fs.writeFileSync('sample.pdf', await src.save()); 

Now a helper that reads the fields back. Note updateMetadata: false; without it, pdf-lib rewrites Producer and ModDate on load, which would hide the thing you are trying to inspect:

async function inspect(bytes) { const d = await PDFDocument.load(bytes, { updateMetadata: false }); return { title: d.getTitle(), author: d.getAuthor(), creator: d.getCreator(), producer: d.getProducer(), keywords: d.getKeywords(), created: d.getCreationDate()?.toISOString(), modified: d.getModificationDate()?.toISOString(), hasXmp: d.catalog.has(PDFName.of('Metadata')), }; } 

Running it on sample.pdf returns the title, author, creator, producer, keywords, both dates and hasXmp: true.

The naive fix

Blank every Info field and save:

const doc = await PDFDocument.load(fs.readFileSync('sample.pdf'), { updateMetadata: false }); doc.setTitle(''); doc.setAuthor(''); doc.setSubject(''); doc.setKeywords([]); doc.setCreator(''); doc.setProducer(''); fs.writeFileSync('naive.pdf', await doc.save()); 

inspect('naive.pdf') now shows empty strings for the text fields, which looks fine. But hasXmp is still true, and both dates are still there. In my run, Buffer.from(bytes).includes('Jane Doe') was true, because the author is still in the XMP stream.

The better fix: nuke the catalog entry too

Deleting Metadata from the catalog looks like the obvious next step:

doc.catalog.delete(PDFName.of('Metadata')); 

hasXmp becomes false, but the byte search for Jane Doe still returned true in my test. pdf-lib's save() writes every object registered in the context, and the XMP stream is still registered even though nothing points at it. The text is still in the file.

The fix that works: copy the pages into a fresh document

A new document starts with no inherited objects, so nothing from the old file comes along except what the pages need:

export async function stripMetadata(bytes) { const src = await PDFDocument.load(bytes, { updateMetadata: false }); const out = await PDFDocument.create({ updateMetadata: false }); const pages = await out.copyPages(src, src.getPageIndices()); pages.forEach((p) => out.addPage(p)); // create() may add its own Info entries; drop whatever is there const infoRef = out.context.trailerInfo.Info; const info = infoRef && out.context.lookup(infoRef); if (info) { for (const key of ['Title', 'Author', 'Subject', 'Keywords', 'Creator', 'Producer', 'CreationDate', 'ModDate']) { info.delete(PDFName.of(key)); } } return out.save(); } 

On sample.pdf this returned a one-page document with no title, no author, no producer, no creation date, no XMP entry, and Buffer.from(cleaned).includes('Jane Doe') was false. The page content was intact.

Two things to know before you rely on this:

  • Copying pages is not redaction. Text on the pages, annotations, embedded files and images keep whatever they contain. A name in a header or in a comment bubble stays. Likewise, pdf-lib does not copy document-level extras that live outside the pages (outlines, form definitions) in every case, so open the result and check that nothing you need is missing.
  • It breaks signatures. Any rewrite invalidates a digital signature. Strip metadata before signing, never after.

How do I check the result without trusting my own code?

Test the output with a second tool. Run exiftool -a -G1 cleaned.pdf if you have ExifTool installed, or strings cleaned.pdf | grep -i "<your name>". The -a -G1 flags make ExifTool list duplicate tags and show which group each came from, which is how you notice an XMP copy that the Info check missed.

For one-off files, use a tool that never uploads the document. Calcenzo has a browser-based PDF metadata remover that inspects the Info dictionary and writes the cleaned pages into a fresh file locally. Its own notes say it is not redaction and does not edit text inside the document, which is the right expectation.

FAQ

Which PDF fields are the most likely to leak something?
Author and Creator/Producer. The first can be a real name or a company account name, and the other two reveal the software and version used. CreationDate and ModDate show when the file was made and last saved.

Is the XMP stream always present?
No. Plenty of simple PDFs have only the Info dictionary. Check for the catalog's Metadata key rather than assuming.

Does flattening or printing to PDF remove metadata?
It replaces the old metadata with whatever the new tool writes, which is usually its own Producer and a fresh date, and sometimes the current user's name. Check the output instead of assuming.

Can I do this in the browser?
Yes. pdf-lib runs in browsers, so the same stripMetadata function works with a File read through arrayBuffer(), and the document never has to leave the machine.

Takeaways

  • PDF metadata lives in the Info dictionary and, often, in an XMP stream. Clear both.
  • Setting fields to empty strings does not delete the old values from the file; unreferenced objects and incremental updates can keep them.
  • Rebuilding the document from its pages is the reliable approach with pdf-lib. Then verify with a byte search and a second tool.
  • Metadata stripping is not redaction. Review the visible content too.