IT
OmnvertImage • Document • Network

PDF redaction that actually works

6 min read
A close-up of shredded paper strips, with fragments of printed words and numbers still readable on them.

Redaction is a data removal problem wearing the costume of a graphics problem. Drawing a box leaves the text exactly where it was in the content stream, and copy and paste exposes it instantly.

Covering is not removing

Nearly every redaction failure comes from one misunderstanding: hiding something in a PDF does not take it out of the file. A page's content stream is an ordered list of drawing operations. The text is painted, then a filled black rectangle is painted on top of it. On screen the second operation hides the first. In the file the first operation is still sitting there, byte for byte. Anyone who selects the region and copies it, runs a text extractor over the document or simply searches it will read what you thought you had removed.

The same applies to highlights and shapes added as annotations. An annotation is a separate object layered over the page; the page content is untouched, and a reader that hides or deletes annotations will happily display the sensitive text underneath. Adding a visual layer is markup, not redaction.

Where the same data survives

Even when the visible text is genuinely gone, the identical information often lives elsewhere in the file. Check the whole list before you call a document clean.

  • Document info and XMP: title, author, subject, keywords, producer. The counterparty's name is frequently in the title, where the reader shows it in the tab.
  • Annotations and comments: review notes, sticky notes, link targets pointing at internal systems.
  • Form fields: a field that renders blank can still carry a value in its object dictionary.
  • Embedded thumbnails: some producers write a preview image per page, and the preview shows the page as it was.
  • The full image data: a photo that looks cropped on the page is stored whole. Cropping only changes the visible box.
  • Optional content groups: a layer that is switched off is still in the file.
  • Attachments and outlines: an embedded source spreadsheet, or a bookmark tree whose entries name the very sections you redacted.

The nastiest one is the incremental update. A PDF can be saved by appending new objects and a new cross-reference section to the end of the file. Earlier versions of those objects physically remain; they are simply no longer referenced. An editor that deletes a page and saves incrementally leaves the deleted page in the file, recoverable by anyone willing to read the raw structure.

What real redaction does

Redaction that holds up has three parts, and skipping any one of them leaves the document exposed.

  1. Remove the content: the glyph runs inside the marked area are deleted from the content stream and the stream is rewritten. Image data under the mark is cropped or repainted at the pixel level.
  2. Clear the side channels: document info, XMP, annotations, form field values, attachments and page thumbnails.
  3. Rewrite the whole file: a full save rather than an incremental one, so no superseded object versions are left behind.

Order matters too. Remove the text, then repaint the area. Check what the mark actually covers: if one letter of a name falls outside the rectangle it will not be deleted, and guessing a surname from its last two letters plus a known context is rarely hard. The PDF redaction tool works from regions you mark on the page.

Four ways to verify the output

Redaction is not something to assume worked. Test the file you produced, never the one you started from.

  1. Extract the text back out: pull text from the output and search it for the redacted string. A hit means nothing was redacted.
  2. Search the raw bytes: extractors decompress streams, so also grep the file itself. Account numbers and addresses turn up in places no text extractor looks.
  3. Read the metadata: list document info and XMP properties. If they are not empty, the cleanup is half done.
  4. Watch the object count and size: if you redacted several pages of text and the file size and object count are unchanged, the content was almost certainly covered rather than removed.

Add one visual check as well: render the page to an image and zoom in on the edges of each black area. Ascenders or descenders peeking out mean the rectangle was drawn too tight.

Three documents, three different risks

A contract exported from Word. The text is vector, so it can be removed cleanly. The risk is in the side channels: title, last author and tracked-change residue that travelled from the source document into the PDF. Emptying document info matters as much as editing the page.

A scanned filing. There are no glyphs to remove; the black box is drawn over an image and the pixels underneath survive untouched. Here the image itself has to be regenerated. If a searchable text layer was added by OCR, that is a second copy of the same words and it needs removing too.

A report from an internal system. Reporting engines produce form fields, thumbnails and layers. The visible table can be spotless while the same figures sit in a field value. This is exactly why checking only the visible text is not enough.

The crude but safe route: flatten to raster

Re-rendering each page as pixels removes the text layer entirely. If the black area is part of the image, there is nothing under it, because there is no longer anything but pixels. The method is decisive and it costs you something:

  • The file grows, since a full-page image replaces compact vector text.
  • Search, copy and screen reader support disappear; accessibility is gone.
  • Print quality is frozen at whatever resolution you chose.
  • The new file has fresh metadata of its own, which you still have to clear.

The sequence is simple: apply the redaction, convert the pages to images, build a new PDF from those images, and then run the four verification steps on the result.

Why blurring and pixelation do not count

Blurring or mosaicking a region reduces information rather than destroying it. When the typeface, size and plausible set of values are known, what remains is often enough to narrow the answer down: a date field has a small number of possibilities, and so does a fixed-length account number. Light blurs can be partially undone by inverting the operation. If information has to go, it has to actually go; making it harder to read is not a redaction method.

Before you send the file

Look at the filename, which often carries a name or a case number. Check what the document title shows in the reader tab, whether the attachments list is empty, and whether bookmarks still name the sections you removed. For scanned material, remember the invisible OCR layer discussed in the piece on OCR quality, and for tabular exports remember that a spreadsheet pulled out of a PDF carries the same content into a new file, which is the subject of the table extraction article.

Images have their own version of this problem, and it usually lives in EXIF: location, device and capture time travel with the photo. The EXIF remover strips those fields. Passwords are a different control again: PDF password protection limits who can open the file but removes nothing, so anyone with the password sees the unredacted content.

One practical caveat: the PDF tools on this site upload your file to a server for processing. For material under a confidentiality obligation, prefer a local tool that never transmits the document, and verify the result on your own machine whichever tool produced it.

Frequently asked questions

Is drawing a black box over the text not enough?

No. The box is a drawing operation appended after the text in the same content stream, so the text operations remain in the file. Copy and paste, text extraction and search all find them. Real redaction deletes the glyph runs and rewrites the page.

How do I verify that a redaction worked?

Extract text from the output and search it for the redacted string, grep the raw bytes as well, list the document info and XMP properties, and see whether the file size and object count changed at all. If all four look right, the job is done.

Is flattening the page to an image safe?

For redaction purposes, yes: nothing but pixels survives. The cost is a larger file, the loss of search and screen reader support, and quality frozen at the resolution you rendered. You still need to clear the metadata of the new file.

Does blurring or pixelating a region work?

It reduces information rather than destroying it. With a known typeface and a constrained set of possible values, the remaining signal often narrows the answer considerably, and weak blurs can be partially reversed. Anything that must be secret should be deleted outright.

Can I just password-protect the file instead?

No. A password controls who can open the document; it removes nothing. Everyone who has the password sees the unredacted content. Password protection is something you add on top of a properly redacted file, not a substitute for one.

Tools used in this post

Sources

MethodologyImage credits