everyday mac tools

How to check whether a PDF was really redacted

· 6 min read

Open the redacted file, press Command-A then Command-C, paste into TextEdit, and read what arrives. If the words you removed are there, the redaction failed. That one test catches most failures; the rest of this post covers the checks that catch the remainder, all of them using what macOS already has.

Run these on the file you are about to send, not on the working copy you redacted. The two are often different files, and the wrong one gets attached.

Check 1: copy everything and read it

  1. Open the PDF in Preview.
  2. Press Command-A, then Command-C.
  3. Open TextEdit, make a new document, press Command-V.
  4. Search the pasted text (Command-F) for each word, name or number you redacted.

This test works because a black box drawn over text does not remove the text; it adds a shape on top. Select All ignores shapes and takes the words. Why a black box on a PDF does not redact anything explains the mechanism.

If the pasted text is empty on a page that clearly has words on it, the page is an image. That is either a scan, which needs a different check below, or a document that was flattened to pictures, which passed this test by losing all its text rather than by being redacted.

Check 2: search inside the file

Still in Preview, press Command-F and type one of the redacted words. Preview searches the document’s text, not what is painted on screen, so a hit under a black box is a failure.

Try a few different words: a surname, a number, a word that only appears in the redacted passage. Search is not case sensitive, but it is exact, so try the form the document actually used.

Then do the same from outside the app. Spotlight indexes PDF text. In Terminal:

mdfind -onlyin ~/Desktop "surname"

replacing the folder and the word. If the file is listed, Spotlight found that word inside it. Spotlight needs a moment to index a new file, so give it a minute after saving.

Check 3: try to move the box

Click the black rectangle. If it grows selection handles, it is an annotation and it can be dragged aside or deleted with one keypress. A real redaction leaves nothing to click; the box, if there is one, is part of the page’s own drawing, and the content under it is gone.

While you are there, open Tools, Show Inspector, and look at the annotations list. A document with a dozen rectangle annotations on it has been covered, not redacted.

Check 4: read the metadata

The words you removed from the page can survive in the document’s own fields. Two places to look.

In Preview, Tools, Show Inspector (Command-I). The general pane shows title, author, subject, keywords, and the creator and producer applications. A title that reads “Smith complaint draft 3” undoes a lot of careful work on the pages.

In Terminal:

mdls ~/Desktop/redacted.pdf

This prints what Spotlight knows about the file, including kMDItemAuthors, kMDItemTitle, kMDItemCreator and kMDItemEncodingApplications. It is the fastest way to see the author field, which Preview’s Inspector sometimes shows and sometimes does not.

Neither view shows everything. XMP metadata, attachments, bookmarks and hidden layers do not appear here. What a PDF still hides covers where else to look. If the document was produced with any of those, the safest course is to strip them; Remove metadata from a PDF on a Mac has the macOS route.

Check 5: extract the text with Automator

Preview’s Select All is good but not exhaustive. Automator, in your Applications folder, extracts every text string on every page regardless of how it is drawn.

  1. Open Automator and choose Workflow.
  2. In the library on the left, find Extract PDF Text under PDFs and drag it into the workflow.
  3. Set the output to Plain Text and choose a folder.
  4. Drag the PDF onto the workflow area, or add a Get Specified Finder Items action above and choose the file.
  5. Click Run.

Open the resulting text file and search it. Save the workflow; you will use it again.

For a scanned PDF this gives you the OCR text layer, if one exists. That layer is the trap with scans: the visible page is an image and the invisible layer contains the words. If the extraction shows the redacted words, the layer was not removed even if the pixels were.

Check 6: look at it somewhere else

Open the PDF in a second viewer: a browser, Quick Look (select the file in Finder and press Space), or a phone. Different viewers handle annotations differently, and one that does not draw them at all shows the page as it really is.

For scans, zoom to the maximum on the redacted area. A box drawn over an image at low resolution can leave a fringe of the original pixels along its edge, or a faint ghost if the box is not fully opaque.

What passes and what does not

A redaction passes when: Select All produces text without the removed words; Command-F and mdfind return nothing for them; the box cannot be selected; the Inspector and mdls show no compromising fields; Automator’s extraction is clean; a second viewer shows the same black.

It does not pass if any one of those fails. A document that fails one check has not been redacted, no matter how clean the other five are.

If the redaction was done in Preview with its actual Redact tool, the page checks usually pass and the metadata checks are where to concentrate. If you need the checking to be built in rather than a manual routine, Basalt does it before writing: every export is re-opened with an independent parser and the removed strings are proven absent, the pixels proven changed and the history proven gone, and a signed certificate is written alongside the PDF so the check can be repeated later with shasum and openssl and without Basalt. If a check fails, no file is written at all.

Questions

The pasted text has strange spacing but no redacted words. Is that a pass? Yes for that check. Real redaction removes glyphs and re-emits what survives; a word broken around a removed phrase can look odd in plain text. Odd spacing is normal; the removed words being present is not.

How do I check a PDF with no text at all? If Select All gives you nothing on every page, the document is images. Check each redacted area at maximum zoom, run the Automator extraction to confirm there is no hidden text layer, and read the metadata. Then decide whether a document that nobody can search is acceptable to send.

Can I trust the redaction tool’s own confirmation? Only as far as you can repeat it. A tool that says “done” is asking you to take its word. A tool that writes a certificate you can verify with standard command-line tools has shown its work. Either way, Command-A and Command-C take five seconds.

Do I need to check every page? Check every page you redacted, and check the metadata once. The Automator extraction covers the whole document in one pass, which is the reason to set it up.