Haven PDFA safe haven for your PDFs
Home › How to redact a PDF properly
● Files never leave your device

How to redact a PDF properly

Drawing a black rectangle over sensitive text does not remove it. It adds one more drawing instruction to a page that still contains the original text, and anyone can copy the text straight back out. This is not a theoretical risk: it is how a Manafort court filing, a TSA screening manual and a Meta antitrust filing all leaked their contents.

This page demonstrates the failure on a file we built for the purpose, shows the actual PDF syntax that causes it, and explains what real redaction has to do instead — plus how to check your own file before you send it.

Choose a PDF

Drag & drop or browse · Your files are never uploaded

How to

  1. Open your PDF in Haven PDF. It loads in the browser; the file is not uploaded to any server.
  2. Select the redaction tool. Drag a box over each piece of information that must be removed.
  3. Export the document. Redacted pages are re-encoded with the underlying content destroyed, not covered.
  4. Verify the export. Open the downloaded file, select the blacked-out area and try to copy. Nothing should come out.

The demonstration

We generated a one-page PDF containing three lines, then drew a filled black rectangle over the middle line — exactly what a highlighter or shape tool does. On screen the line is perfectly hidden. Then we extracted the page text with a standard library, which is the same thing your browser does when you select and copy:

$ node extract-text.mjs fake-redacted.pdf

CONFIDENTIAL - internal only
Account: TR33 0006 1005 1978 6457 8413 26   <-- supposedly redacted
Approved by: J. Smith
Text extracted from the “redacted” PDF. The black bar is visible on screen; the data is not hidden from software.

Why it fails: a PDF page is a list of drawing instructions

A PDF page is not a picture. It is a content stream: an ordered list of operators that a reader executes, top to bottom, like a tiny drawing program. Text is drawn by a show-text operator; a rectangle is drawn by a fill operator. Painting a rectangle later in the list simply covers earlier output — nothing is deleted, because the format has no “erase” instruction.

BT
  /Helvetica 12 Tf
  1 0 0 1 40 110 Tm
  <4163636F756E743A205452333320303030362031303035...> Tj   % <- the secret, STILL HERE
ET

q
  0 0 0 rg                  % black fill
  1 0 0 1 36 104 cm
  0 0 m  0 18 l  320 18 l  320 0 l  h
  f                         % paint the rectangle - OVER the text, not instead of it
Q
The real content stream of the file above, trimmed. The hex string is the account number; the rectangle is appended after it.

The hex string is the sensitive text, still fully present. Text extraction never rasterises the page — it walks these operators and collects what the show-text ones carry. From that perspective the rectangle is irrelevant: it is drawn later, in a different operator, and it does not touch the string at all.

The three failures that keep happening

A fourth failure is subtler: removing the visible text but leaving the same information in document metadata, in an attachment, in the bookmark titles, or in an earlier revision preserved by an incremental save. A PDF can keep its own history — saving repeatedly appends changes rather than rewriting the file, and the previous version stays inside.

It has happened repeatedly, to people with lawyers

The pattern is consistent: the people making the mistake were not careless amateurs, they were organisations with legal review. The failure mode is the tool, not the diligence.

What real redaction has to do

To remove content rather than hide it, an editor has exactly two honest options. It can rewrite the content stream, deleting the show-text operators that fall inside the redaction area and re-encoding the page. Or it can rasterise the page — render it to pixels, destroy the pixels under the redaction area, and embed the result as an image, at which point there are no text operators left to extract.

Haven PDF takes the second route for redacted pages: the page is rendered, the pixels beneath each redaction box are overwritten before anything is embedded, and the output page carries no recoverable text. Pages you did not redact are left untouched and keep their selectable text.

We keep an automated test that opens a document, redacts a heading, exports, and then fails the build unless the phrase is absent from both the extracted text layer and the raw file bytes. Verifying the negative is the only way to know redaction still works after a code change.

Check it yourself before you send it

  1. Open the exported file in any reader and try to select the blacked-out region. If a selection highlight appears over it, the text is still there.
  2. Select the whole page, copy, and paste into a plain text editor. Search for the sensitive string.
  3. Search the document for a word you redacted using the reader’s own find function. A hit means it survived.
  4. If the file matters, also check the document properties and any attachments — metadata is redacted by nobody by default.

Why redaction should not happen on someone else’s server

Redaction is applied to precisely the documents that must not leak: contracts, medical records, filings, identity documents. Uploading such a file to a web service to have the secret removed means the unredacted original is transmitted, processed and — for some period — stored by a third party. The redaction succeeds; the confidentiality has already been spent.

Haven PDF runs entirely in your browser. The document is opened, rendered, redacted and re-encoded on your own machine, and no copy is uploaded anywhere. That property is not a marketing line here — it is the whole reason the tool is built the way it is.

Open the redaction tool · How Haven PDF works

Frequently asked questions

Is drawing a black rectangle ever enough?
No. The text remains in the page content stream and comes straight back out with copy-paste or any extraction tool. We demonstrate exactly this above on a file we built for the purpose.
What about making the text white instead?
Worse, if anything: the glyphs are still drawn and still extractable, and now they are invisible even to you when you proofread the document.
Does redaction remove metadata too?
Redaction acts on page content. Author names, titles, attachments and bookmark text live elsewhere in the file and must be checked separately — open the document properties before you send anything sensitive.
Why does my redacted page look slightly different?
Because a redacted page is rasterised so that no text operators survive. The visual result is the same page, but it is now an image: text on that page is no longer selectable, and the file is usually a little larger. Pages without redactions are untouched.
Can redacted text be recovered from your output?
Not by extraction: there are no text operators left, and the pixels underneath were overwritten before the image was created. We test this automatically against both the text layer and the raw file bytes.

Sources

  1. American Bar Association — “Embarrassing Redaction Failures”, The Judges’ Journal (2019) — Overview of documented court-filing redaction failures.
  2. Columbia Journalism Review — on the Manafort filing redaction failure — Reporting on how the blacked-out passages were recovered by copy-paste.
  3. ISO 32000-2:2020 — Document management: Portable Document Format — Content streams and text-showing operators (§8, §9): why painting cannot delete.

Related tools