everyday mac tools

Why a black box on a PDF does not redact anything

· 5 min read

A black rectangle drawn over text in a PDF hides it on screen and nowhere else. The text is still in the file, and anyone who selects all and copies, searches the document, or opens it in a different viewer gets it back in seconds. Redaction means removing content from the file; a shape on top of it is a sticker.

This post explains what a PDF page is made of, why that makes covering useless, and what a real redaction has to do instead.

What a PDF page actually contains

A PDF page is not a picture. It is a list of drawing instructions: put this glyph here in this font, draw this image at these coordinates, fill this rectangle with this color. A viewer runs the list from top to bottom and paints the result.

When you draw a box over a name, you add one more instruction at the end of the list: fill a black rectangle here. The instruction that placed the name is still earlier in the list, untouched. The viewer paints the name, then paints the box over it, and you see black. The file contains both.

Most annotation tools do not even put the box in the page’s own instruction list. They store it as an annotation, a separate object attached to the page that any viewer can show, hide, move or delete. That is the whole point of annotations: they are removable by design.

The three ways people draw a box, and what each leaves behind

A rectangle shape in Preview. Tools, Annotate, Rectangle, then a black fill from the Markup toolbar. This is an annotation. Anyone can click it and press Delete, or drag it aside. The text underneath was never touched.

Black highlighting in a word processor, then export to PDF. The exporter writes the text as text and the highlight as a filled rectangle behind or over it. Select all in the PDF and copy: every word is there. This is the version that ends up in the news, because it looks perfectly redacted in print.

A black box on a scanned page. The page is an image, so the box has to be an annotation or a second image drawn on top. The original scan is still embedded in full. If the scan was made searchable, there is also an invisible text layer underneath, and that layer contains the words you were trying to hide. Redacting photos and scans inside a PDF covers that case on its own.

None of these is a redaction. All of them look like one.

Five ways the text comes back

You can try each of these on your own Mac with a covered PDF and watch it fail.

  1. Select all and copy. Open the PDF in Preview, press Command-A, then Command-C, and paste into TextEdit. The covered words arrive with everything else.
  2. Search. Command-F in Preview, type a word you covered. Preview finds it and highlights the spot under the box.
  3. Move the box. Click the black rectangle. If it grows handles, it is an annotation. Drag it. Press Delete.
  4. Extract the text. Automator, which ships with macOS, has an action called Extract PDF Text. Drop the file on a workflow built from that one action and you get a plain text file of everything on every page, boxes ignored.
  5. Open it somewhere else. A different PDF viewer, a browser, a phone. Some of them do not render annotations at all, so the box simply is not there.

There is a sixth that people forget: Spotlight. If the PDF is on your Mac, Spotlight has indexed its text, box and all. mdfind "the surname" in Terminal will list the file.

Pictures are not safer

A common fallback is to print the covered PDF to a fresh PDF, or to screenshot each page, on the theory that flattening bakes the box in. Sometimes it does; the text under the box is gone because the page has been re-rendered as an image or re-drawn from what was visible.

Two problems. First, you now have a file with no selectable text at all, on every page, including the ones you did not redact. Second, the rest of the document has not been considered. The title, author and keywords fields, the XMP metadata block, bookmarks, attached files, the thumbnail images some producers embed for each page, and any hidden layers all travel with the file and can carry exactly the words you removed from the page. What a PDF still hides goes through those one at a time.

What real redaction has to do

Redaction is destruction, done in a specific order.

First, the text under the mark is removed from the page’s instruction list, glyph by glyph, and what survives is written back in place so the rest of the line still reads. Second, any image under the mark is altered at the pixel level and re-encoded, so the original picture no longer exists in the file. Third, everything outside the page is stripped or checked: document metadata, XMP, attachments, layers, bookmarks and stale thumbnails.

Then the result is checked. Not by looking at it, which is how the covered version passed in the first place, but by re-opening the output and searching for the strings that were supposed to be gone.

Preview can do the first part. Since macOS 11 it has a real Redact tool under the Tools menu that removes the content beneath the mark rather than covering it. Redacting a PDF in Preview walks through it and where it stops. For document sets where a miss is expensive, Basalt is built around this: the text is excised glyph by glyph, images under marks are destroyed and re-encoded, metadata and attachments and layers are stripped, and a verifier re-opens the export with an independent parser and proves the strings are absent before any file is written. If a check fails, no file is written.

Before you send anything

Whatever tool you used, run this on the output, not the working copy.

  1. Command-A, Command-C, paste into TextEdit. Read it.
  2. Command-F for two or three of the words you removed.
  3. Tools, Show Inspector, and read the title, author, subject and keywords.
  4. In Terminal, mdls on the file, and look at the author, title and creator lines.
  5. Open it on a phone, or in a browser, and look at the pages again.

How to check whether a PDF was really redacted expands each step. A minute of checking is the difference between a redaction and a black box.

Questions

I flattened the PDF and the text no longer copies. Is it safe now? The page is probably safe. The document may not be: metadata, bookmarks and attachments survive flattening. Check the Inspector and mdls before you decide, and remember that the flattened file has lost its searchable text everywhere, not only under the boxes.

Does a scanned document need redacting at all if there is no text layer? Yes. A box over a scan is an annotation over an image; the image is intact underneath. The scan has to be altered at the pixel level and re-encoded, and any text layer that was added by OCR has to be removed too.

Can I redact with a white box instead of a black one? The color does not matter. A white rectangle is the same annotation with a different fill, and the text under it is just as present. Choose black because it makes the redaction visible to the reader, which is usually what a court or a records officer expects.

Why do so many published documents get this wrong? Because the covered version and the redacted version look identical on screen and in print, and nobody checks the file itself. The check is the step that gets skipped.