What Does It Mean to Sanitize a PDF? Hidden Data Removed
To sanitize a PDF (sanitise, in British spelling) means removing the content that sits behind the visible page: scripts, embedded files, metadata, form data, links and similar extras. A sanitized PDF should show the same pages but carry nothing the reader cannot see. It is different from redaction, which removes content on the page itself.
People sanitize files before publishing them, before sending them to a regulator or partner, and before opening or forwarding a PDF from an unknown source. This guide explains what hidden data a PDF can carry, what our Sanitize PDF tool removes step by step, how that differs from Remove Metadata, and how to check the result.
What hidden data can a PDF carry?
The PDF standard, ISO 32000-1:2008, provides for several kinds of content that are not part of the drawn page:
- Metadata in two places: the document information dictionary and XMP metadata streams (section 14.3.1). Both can hold author names, titles and the software used.
- JavaScript, which can run when the file opens, when a page opens or when a form field changes (section 12.6.3 on trigger events and 12.6.4.16 on JavaScript actions).
- Embedded files, whole documents carried inside the PDF (section 7.11.4), and file attachment annotations placed on pages (section 12.5.6.15).
- Form fields and their values (section 12.7).
- Annotations such as comments, highlights and stamps (section 12.5), and links to web pages or other places.
- Optional content or layers that can be hidden (section 8.11), and earlier versions kept by incremental updates (section 7.5.6).
The US National Security Agency's redaction guide (report I333-015R-2005) lists metadata and document properties as one of the three common mistakes that lead to unintended exposure, and notes that this hidden information is often as sensitive as the document itself.
What Sanitize PDF does, step by step
Sanitize PDF runs in your browser and works on one file at a time. It has six options. Five are ticked by default; Remove Annotations is not. Here is exactly what each does in the current version:
- Flatten Forms draws each form field's appearance onto the page and removes the fields. If that fails, it removes the form definition (the AcroForm entry) instead, which can leave the field boxes on the pages.
- Remove Metadata empties the document information dictionary, so the title, author, subject, keywords, creator and the creation and modification dates are gone, and sets the producer to "Priya LifePDF". It also removes the document-level XMP metadata.
- Remove Annotations (off by default) deletes every annotation on every page, including comments, highlights and stamps.
- Remove JavaScript deletes the document-level JavaScript list, the action that runs when the file opens, and the additional actions attached to the document and to each page.
- Remove Attachments deletes the list of embedded files and any portfolio (collection) structure.
- Remove External Links deletes link annotations. Despite the label, it removes all links, including links that jump to another page in the same document.
After processing, the tool lists the steps it ran; an item can appear in that list even when the file had nothing of that kind. The file is saved as a new copy with _sanitized in its name.
What it does not remove
Knowing the gaps matters as much as knowing the steps:
- Anything on the page. Text under black boxes, white or invisible text, and content outside the crop box are untouched. That is a job for proper redaction.
- Layers. Hidden optional content stays in the file.
- Some scripts. JavaScript attached to bookmarks, or to annotations other than links and form fields, is not searched for. If Remove Annotations is ticked, scripts on annotations go with them.
- Page-attached files. File attachment annotations on a page stay unless Remove Annotations is ticked.
- The removed data's bytes. The tool unlinks items so that PDF readers no longer show or run them, then saves the file. In our own test of the current version, the content of a removed attachment and of the removed XMP block could still be found in the raw bytes of the saved file, although no reader displays them. For most sharing that is acceptable. For a sensitive release, treat it as a reason to check, or to create the PDF again from the source document.
Sanitize PDF compared with Remove Metadata
The two tools are easy to confuse. Remove Metadata is the lighter one:
| Item | Remove Metadata | Sanitize PDF |
|---|---|---|
| Title, author, subject, keywords, creator, producer | Cleared | Cleared (producer set to Priya LifePDF) |
| Creation and modification dates | Kept; the modification date becomes the time you processed the file | Removed |
| XMP metadata | Not touched | Document-level XMP removed |
| JavaScript | Not touched | Document, open and page actions removed |
| Embedded files | Not touched | Document-level list removed |
| Form fields | Not touched | Flattened |
| Links and annotations | Not touched | Links removed; annotations optional |
The XMP point matters because XMP often repeats the author and the creating software. A file run through Remove Metadata can look clean in a properties dialog and still carry the same names in XMP. Our guide on how to remove metadata from a PDF explains the dates and the Producer field in more detail.
How to check a sanitized PDF
- Open the new copy in View Metadata. Title, author and dates should be empty. View Metadata reads the document information dictionary only, not XMP.
- Run Extract Attachments on the copy. It reports both document-level and page-level attachments, so any that remain will show.
- Open the copy in a full PDF reader and check the comments, attachments and layers panels, and that the form no longer responds to clicks.
- Select all text, paste it into a plain text editor and read it against the pages, to catch hidden text that sanitizing does not cover.
- For a high-stakes release, search the raw file. The free qpdf tool's
--qdfmode writes a copy with streams uncompressed that you can search in a text editor:qpdf --qdf --object-streams=disable sanitized.pdf check.pdf. Searchcheck.pdffor names, file names and project codes.
When sanitizing is part of a regulated workflow
Submission rules already ask for much of what sanitizing removes. The FDA PDF Specifications (v4.1) state that PDF files must not contain JavaScript, dynamic content, attachments or 3D content, and say not to include PDF annotations. The EMA harmonised eCTD guidance (version 6.0.1, section 2.9.2) says other file formats should not be embedded within a PDF file but submitted as standalone files. Sanitizing a final PDF is a reasonable last check against those rules, but the publishing process and its own checks stay in charge; see our notes on preparing PDFs for regulatory submissions.
Two cautions for GMP records. First, sanitizing changes the file, so a sanitized copy is a new document, not the original record, and links, comments or attachments it removed may have been part of that record. Second, a digitally signed PDF loses its valid signature when it is rewritten. Sanitize a copy made for sharing, keep the original under your document control procedure, and ask QA if you are not sure which version a recipient should get. This is general information, not regulatory advice.
Tools mentioned in this article
Frequently asked questions
What is the difference between sanitizing and redacting a PDF?
Redacting removes chosen content from the page, such as a name or a figure. Sanitizing removes content behind the page, such as metadata, scripts, attachments and form data. A file being released often needs both.
Does sanitizing a PDF remove the author name?
Sanitize PDF clears the author, title and other document properties and removes the document-level XMP metadata. Names typed on the pages themselves, for example in a footer, stay until you edit or redact them.
Will sanitizing change how the pages look?
Mostly no. Filled form fields are drawn onto the page, although fields without a stored appearance are redrawn in a standard font. Links stop working, and comments disappear only if you choose to remove annotations.
Is a sanitized PDF safe to open?
Removing JavaScript, open actions and attachments reduces the ways a PDF can act on your computer, but it does not inspect fonts, images or other content for exploits. Use your organisation's security tools for files from unknown sources.
Can I sanitize a signed PDF?
You can, but the copy will no longer carry a valid digital signature, because the file is rewritten. Keep the signed original and sanitize a separate copy for sharing.
Sources
- ISO 32000-1:2008 (PDF 1.7), free copy published by Adobe: sections 7.5.6, 7.11.4, 8.11, 12.5, 12.6.3, 12.6.4.16, 12.7 and 14.3
- NSA: Redacting with Confidence, How to Safely Publish Sanitized Reports Converted From Word to PDF (I333-015R-2005)
- FDA: Portable Document Format (PDF) Specifications, v4.1 (September 2016)
- EMA: Harmonised technical guidance for eCTD submissions in the EU, version 6.0.1
- qpdf documentation: command-line options (--qdf, --object-streams)
