DocumentSpace
/Blog/
How to Remove Sensitive Metadata From a PDF Before Sharing
PDF Security

How to Remove Sensitive Metadata From a PDF Before Sharing

Mohamed SirajMohamed Siraj··13 min read
TL;DR

A PDF you share outside your organization often carries far more information than its visible pages. The document properties can name the author and the company, record when the file was created and last changed, reveal the software and version used to produce it, and sometimes preserve earlier drafts in the file itself.

How to Remove Sensitive Metadata From a PDF Before Sharing

Table of Contents

Article illustration

  1. What metadata a PDF actually contains
  2. Why it matters for legal, HR and finance teams
  3. Where the sensitive information hides
  4. Inspecting a PDF before you clean it
  5. Removing metadata at the source
  6. Removing metadata from the finished PDF on Mac
  7. Removing metadata from the finished PDF on Windows
  8. Removing metadata on Linux with exiftool and qpdf
  9. Handling hidden revisions and old versions
  10. Verifying that the cleaning worked
  11. What remains after sanitization
  12. A repeatable sanitization workflow

What metadata a PDF actually contains

PDF metadata lives in more than one place, and cleaning only one of them is a common mistake.

The first place is the document information dictionary, referenced from the trailer. It holds the classic fields: Title, Author, Subject, Keywords, Creator, Producer, CreationDate and ModDate, along with optional fields such as Trapped. The Creator field usually names the application that created the document, such as a word processor. The Producer field names the library or driver that wrote the PDF, which can reveal the software version. Both fields are plain text, and in many workflows they are populated automatically.

The second place is the XMP metadata stream, an XML packet attached to the document catalogue. XMP is the more modern and more flexible format, and it often repeats the information dictionary's fields in a richer form. It can also contain fields the dictionary does not have, including the history of edits. A file can carry the same author name in both places, and cleaning one while leaving the other is a frequent source of leftovers.

The third place is the file identifier in the trailer, which contains two identifiers: one for the original creation and one for the latest revision. These are usually random hashes, not names, but they can link documents to a specific generation process or to other files produced by the same system.

The fourth place is the content itself: the text and images on each page, and the objects that support them. Images can carry their own EXIF data. Annotations can contain author names and timestamps. Form fields can record the names of the people who filled them. Bookmarks, named destinations and tagged structure can include text that is not visible on the page.

The fifth place is the revision history. A PDF saved incrementally keeps earlier versions of changed objects in the file, appended after the original content. The visible document may show only the latest state, while the file still contains the original text of a paragraph that was deleted or a comment that was resolved.

Why it matters for legal, HR and finance teams

Article illustration

Metadata is often the most revealing part of a document that is shared externally. A draft contract that names the internal negotiator and the editing history is exposing the organization's process. An HR letter that carries the name of the employee who wrote it, the department's internal file path or the editing history of a disciplinary draft can reveal more than the text does. A finance report whose metadata shows a template name and a software version can help an attacker target the system that produced it.

Personal data is also involved. Under the EU General Data Protection Regulation, personal data includes information that identifies a person directly or indirectly. An author's name or a machine identifier in a PDF may qualify, and the principle of data minimization in Article 5 expects organizations to share only what is necessary for the purpose. Removing unnecessary metadata is one practical way to meet that expectation, although the legal analysis for each document depends on its context.

Finally, there is the question of what the recipient learns from the file's history. If a contract was negotiated through several drafts and the file still contains the earlier clauses, the recipient may see positions the sender never intended to disclose. Revision leftovers are a classic source of embarrassment, and sometimes a legal problem.

Where the sensitive information hides

Before you clean a file, list the places where information is likely to live, because that list tells you which tools to run and what to check.

Common locations include:

  • Author, Company and Manager fields, in the information dictionary and the XMP stream.
  • Creator and Producer fields, which name the software and its version.
  • Editing and creation dates, which can reveal working patterns or time zones.
  • Comments and annotations, including sticky notes, highlights and stamps with author names.
  • Tracked changes and deleted text, when a document was exported from a word processor with revisions still visible in the file.
  • Embedded images with EXIF or XMP data, including GPS coordinates recorded by a phone or camera.
  • Embedded files and attachments, which can include spreadsheets or source documents.
  • Form fields with recorded values, names or signatures that were not meant to be shared.
  • Hidden layers, optional content groups and off-page objects.
  • Bookmarks, page labels and named destinations with descriptive names.
  • Thumbnail images, which can show an earlier version of a page.
  • Earlier revisions preserved by incremental saves.

The last two items are the hardest to see. We address them in their own section below.

Inspecting a PDF before you clean it

Article illustration

Inspection comes first, because you cannot verify a clean output without knowing what you were looking for. The best inspection tool for metadata is exiftool, an open-source command-line utility maintained by Phil Harvey and documented at exiftool.org. It reads both the information dictionary and the XMP stream, and it works on Mac, Windows and Linux.

Install exiftool with your package manager, or download the standalone version from the official site. On macOS, Homebrew provides a package. On Windows, use the executable distribution from the official site. Then run:

exiftool -a -G1 -s draft-contract.pdf

The -a option shows duplicate tags, -G1 groups the output by family, and -s shortens the tag names. This output will show the fields from the information dictionary and the XMP stream side by side, which lets you spot disagreements between them.

To inspect the embedded images, add the -ee option, which extracts embedded metadata from within the file's streams:

exiftool -ee -G1 -s draft-contract.pdf

Look for GPS fields, camera make and model, serial numbers and timestamps that do not match the document's creation date.

For a second opinion on the document's structure, use poppler's pdfinfo, which summarizes the information dictionary and page count. Use pdfinfo -meta where your version supports it to view the XMP packet. Check the page count, the page size and any encryption settings, and note the Producer value.

Finally, look for the annotation and attachment layer in Acrobat Pro through the Comments and Attachments panels, or through the Document Properties dialog. Acrobat shows the document's properties and its security settings, which may affect the cleaning steps you can take.

Removing metadata at the source

The most reliable way to produce a clean PDF is to clean the original document before exporting it. Once a file has been converted to PDF, you are working with the output of a converter that may have added its own metadata, and you may not be able to see the editing history that the converter kept.

In Microsoft Word, use File, then Info, then Check for Issues, then Inspect Document. The Document Inspector checks for comments, revisions, document properties and personal information, hidden text, and other content types. Remove the items that do not belong in the external copy, then save or export. Make sure the revision marks are accepted or rejected, not just hidden, because a hidden revision can still be recovered from the document.

In Word, also check the document properties under File, then Info, and remove the author and company fields if they are not appropriate. Be aware that the last-modified-by field and the revision count are stored in the document and may survive export, depending on the converter.

In Excel and PowerPoint, the equivalent steps are in the same Info and Inspect menus. Remove hidden slides, notes and sheets that are not part of the external copy, because they will survive into the PDF if they are printed or exported.

When you export to PDF from Office, choose the option that produces the smallest set of document properties and check the output. On macOS, the Print dialog's Save as PDF function uses the system's PDF engine, which typically writes a new file with fewer properties than the source. It still leaves the producer field, and it does not remove embedded images' metadata.

Removing metadata from the finished PDF on Mac

On macOS, you have three levels of cleaning, and you should use the one that matches your risk.

The lightest is Preview's Inspector. Open the PDF in Preview, choose Tools, then Show Inspector, and look at the document's properties. Recent versions of Preview allow you to view and in some cases edit a limited set of document fields. This is useful for removing an obvious author name or title, but it does not reach XMP packets, embedded images, or revision history, and it cannot be relied on to produce a verified-clean file.

The second level is print to a new PDF. Open the file, choose File, then Print, then Save as PDF from the PDF menu at the bottom of the dialog. The output is a new file, rendered by macOS's PDF engine. This removes many structural leftovers, including earlier revisions, because the new file contains only the objects needed for the page content. Some properties may still be carried over, notably the producer field, so inspect the result. Note that this approach rasterizes nothing: text remains text, so you still need to check that hidden text is not present in the new file.

The third level is the command-line route, which we describe in the Linux section. Install exiftool and qpdf through Homebrew, and run the same commands. This gives you the most control and the best verification.

Acrobat Pro on macOS also offers the Sanitize Document function, which removes hidden information such as metadata, comments, attachments and hidden layers. Its location depends on the Acrobat version, so search the Tools panel for "Sanitize" if you cannot find it in the menu. Sanitize is a good first pass, but verify its output with exiftool afterwards.

Removing metadata from the finished PDF on Windows

On Windows, the operating system's file property editor is not reliable for PDFs. Right-clicking a PDF, choosing Properties, then Details, and selecting Remove Properties and Personal Information is designed for Office documents and may not clear the PDF's XMP packet, the information dictionary, or any embedded image metadata. Do not rely on it for sensitive files.

Acrobat Pro on Windows offers the same options as on macOS. Open the file, choose the Tools panel, search for Sanitize Document, and run it with the options for metadata, comments, hidden information and attachments. Save as a new file rather than overwriting the original, so that you keep an unclean copy under your own control.

Print to PDF using the Microsoft Print to PDF driver, which is built into Windows 10 and Windows 11, will produce a new file with fewer carried-over structures. As on macOS, verify the result, because some properties can remain.

For Windows administrators, the most robust approach is to install the command-line tools. Exiftool provides a Windows executable, and qpdf is available from its project website and through common package managers. A PowerShell script that runs both tools over a folder, and writes a report of the results, gives you a repeatable process that a non-specialist can run. Keep the script in a shared location with version control, and treat the report as part of the file's release record.

Removing metadata on Linux with exiftool and qpdf

Linux gives the most transparent route. The workflow below uses exiftool to remove the metadata it knows about, qpdf to rewrite the file and drop unreferenced objects, and a final inspection to verify the result.

Start by removing the information dictionary and XMP metadata with exiftool. The -all= option clears all writable tags:

exiftool -all= -overwrite_original draft-contract.pdf

The -overwrite_original option stops exiftool from creating a backup. Use it only once you have a safe copy of the original. Exiftool's documentation notes that PDF writing is not guaranteed to remove every item, so treat this as a first pass and check the result.

Next, rewrite the file with qpdf, which reads the file and writes a new one. A plain rewrite produces a file that contains only objects reachable from the trailer, which removes many unreferenced leftovers, including some older revisions. Add the --object-streams=disable option if you want an uncompressed structure that is easier to inspect with text tools:

qpdf --object-streams=disable draft-contract.pdf clean-contract.pdf

Qpdf can also show the structure of the output in a readable form, which is useful for verification:

qpdf --qdf --object-streams=disable clean-contract.pdf clean-contract-qdf.pdf

The QDF format decompresses streams and writes objects in a readable layout. You can then search it for names and strings. Do not use the QDF output as your shared file, because it is larger and intended for inspection.

For programmatic workflows, the pikepdf library exposes the information dictionary and the catalogue's metadata entry directly. You can remove them in code and save the file, which is useful when you process many documents. Test on a copy before running a batch, and log which fields you removed.

Handling hidden revisions and old versions

The most dangerous leftovers are the ones you cannot see in a viewer. A PDF edited with an incremental save keeps the original objects and appends new ones. Anyone who parses the file can find the earlier text, even though the viewer shows only the latest state.

To check for incremental updates, count the trailers and cross-reference sections in the file. The qpdf tool reports the number of xref sections it finds, and the --check option reports structural issues:

qpdf --check clean-contract.pdf

A file that was written by a single full save usually has one cross-reference section. Multiple sections indicate that the file was updated incrementally, and the earlier content may still be present.

The remedy is a full rewrite. The qpdf rewrite described above removes unreferenced objects, which includes many earlier revisions. However, a rewrite does not change the content of objects that are still referenced. If a page's content stream was edited and the old text is still referenced by a form field or annotation, the old text remains. Inspect the page content and annotations, not only the page as displayed.

Thumbnails are a separate case. Some PDF writers store thumbnail images for each page, and those images can show an earlier version of the page. Remove them by rewriting the file through a tool that discards the thumbnail entries, or by printing the document to a new PDF, which creates new thumbnails from the rendered output.

If you need certainty about what the file contains, rasterize the pages to images and rebuild the PDF from them. This destroys searchable text and any hidden layers, but it leaves no revision history and no metadata of the original. It is a heavy approach, and it is appropriate for a small set of very sensitive documents where legibility is preserved but structure is not.

Verifying that the cleaning worked

Verification is the step most often skipped, and it is the only way to know that cleaning worked. Use the same tools you used for inspection, and compare the outputs.

Run exiftool again on the cleaned file, and confirm that the author, company and creator fields are empty or set to generic values. Check the XMP fields as well. Look for the GPS fields in any embedded images.

Run pdfinfo on the cleaned file, and confirm that the producer field is as you expect.

Search the raw bytes of the file for the names and terms you expect to be removed. Because object streams are compressed, you should first produce a QDF version with qpdf, then search it:

qpdf --qdf --object-streams=disable clean-contract.pdf check.pdf
grep -a -i "author\|company\|xmpmeta" check.pdf

If the search returns no hits for the fields you intended to remove, you have a good sign. If it returns hits, identify the object and decide whether it is legitimate or a leftover. Do not assume the search is complete, because some content may be stored in forms that a simple search does not match, such as encoded strings.

Finally, open the cleaned file in two different viewers. Check that the visible content is correct and that no unexpected annotations or form fields are present. Use a text extraction tool, such as poppler's pdftotext, to see what text a machine can recover, and compare it to what you expect the reader to see.

What remains after sanitization

Even a thorough cleaning leaves some information in the file, and you should know what it is.

The visible text and images remain, of course. Their content is the reason you are sharing the document. Hidden text under images, text outside the crop box and text in very small fonts also remain unless you removed it at the source.

Font names may remain. Embedded fonts carry names, and subset fonts carry random tags. These rarely identify a person, but they can identify a font family, which may reveal the organization's brand or template.

The document identifier is regenerated when you save, but a file rewritten by a tool that preserves the original identifier will keep it. Check the trailer if linkage across documents is a concern.

Page labels, language tags and tagged structure remain if present. Tagged PDFs carry structure that describes headings and reading order, which is useful for accessibility and can be left in place.

Producer and creator fields often remain after printing to PDF, because they describe the output tool rather than the author. If the software version is sensitive, overwrite these fields with generic values after cleaning, and verify again.

Image pixels are not metadata, but an image can show the content of a screen, a face, a whiteboard or a document photographed on a desk. Metadata cleaning does not remove visual information. Review the images, not only the fields.

Keep these limits in mind when you describe the file to a recipient. A cleaned PDF is cleaner, not blank. It has been stripped of the material that does not belong in an external copy.

A repeatable sanitization workflow

For teams that share documents regularly, a standard workflow beats ad hoc cleaning. The following sequence works for most organizations.

  1. Clean the source document in its native application, using the document inspector and the removal of comments, revisions and hidden data.
  2. Export to PDF, using the smallest set of options that produces the output you need.
  3. Keep the export as the working copy. Never overwrite the original.
  4. Run exiftool to remove the information dictionary and XMP metadata, and check the result.
  5. Rewrite the file with qpdf to drop unreferenced objects.
  6. Inspect the result with exiftool, pdfinfo and a QDF search, and open it in two viewers.
  7. Record the steps, the tool versions and the verification output in your document register.
  8. Share the cleaned file through a channel that suits its sensitivity, such as a secure link, and keep the original in your records.

If the document contains personal data, consider whether it should be shared at all, or whether it should be anonymized first. Our guide on anonymizing customer data before sharing covers that decision. If the file is to be encrypted, do the metadata cleaning before encryption, because a tool that cannot read the encrypted file cannot clean it.

Finally, remember that metadata cleaning is one layer of protection. For how to protect the document's contents from copying and screenshot capture, read our guides on sharing a PDF without download and protecting a PDF with a dynamic watermark. For the question of how the file itself is protected, our article on encrypting a PDF file explains what encryption does and does not do.

Questions people ask

It removes many categories of hidden information, but it is not a guarantee. Verify the output with exiftool and a QDF search, particularly for incremental updates and embedded images.

Mohamed Siraj

Mohamed Siraj

Founder, SecureTools.live

LinkedIn