How to Redact a PDF Properly, and Check It Worked


Share this article
The black bar looks perfect. The name under it is still in the file, and anyone with a free command-line tool can read it in under a second.
That’s the redaction failure people hit most, and it’s the one we reproduced for this guide. We built a fictional patient record, blacked out the name, email, and Social Security number the way most people do, and ran one command against it. Every “hidden” value came straight back out.
What actually happens when you draw a black box
Here’s the thing about PDFs: a page isn’t a picture. It’s a list of drawing instructions. One instruction draws the text “Daniel Reyes” at a position, and a later one draws a black rectangle at the same position. Your viewer paints them in order, so the rectangle wins on screen.
Text extractors don’t care about paint order. They read the text instructions and ignore the rectangle, because a rectangle isn’t text. So the redaction only exists for human eyes.
This is the file we tested, a two-page intake record with black rectangles drawn over the name, email, and SSN:
$ pdftotext -f 1 -l 1 black-box-redaction.pdf -
Riverside Family Clinic
Patient intake summary
Name: Date of birth: Phone: Email: SSN: Address:
Daniel Reyes 04/12/1986 (555) 014-2290 [email protected] 123-45-6789 410 Elm Street, Springfield
Notes
Daniel Reyes reported mild seasonal allergies and no current medication. Follow-up visit booked for the next quarter. Contact by phone first.
The metadata leaked too. The document title still named the patient:
$ python -c "from pypdf import PdfReader; print(PdfReader('black-box-redaction.pdf').metadata)"
{'/Producer': 'pdf-lib (https://github.com/Hopding/pdf-lib)', ..., '/Title': 'Daniel Reyes medical record', '/Author': 'Riverside Family Clinic'}
This exact mistake has embarrassed real legal teams. The black bars in a 2019 court filing by Paul Manafort’s lawyers could be copied and pasted into plain text, as the ABA Judges’ Journal documented. The NSA’s own guide, Redacting with Confidence, puts the rule bluntly: delete sensitive content, don’t cover it.
What not to do
Most people try one of these first. They all leave the original content behind.
| What people try | What you see | What stays in the file |
|---|---|---|
| Black rectangle in a PDF editor | Covered text | All of the text under it |
| Black highlight in Word, then Save as PDF | Covered text | The text, now in the PDF |
| A comment or annotation box | Covered text | The text, plus a box anyone can delete |
| White font or a white box | Blank space | The text, invisible but searchable |
| Cropping the page | Text out of view | The cropped content, outside the visible area |
| Blur or pixelate in an image editor | Blurred text | Pixels that can be reversed |
That last one surprises people. A 2016 study recovered text from mosaic and blur filters, and tools such as Unredacter now automate the attack. Solid boxes are the only safe visual cover, and only when the content underneath is gone.
Fix 1: Remove the content instead of covering it
Real redaction deletes what is under the box. In Redact PDF, every page with a redaction is drawn as an image, your boxes are painted into the image’s pixels, and the page is rebuilt from that image. The original text and fonts on that page never make it into the new file.
Leave Remove hidden document data on. It’s the default, and it rebuilds every page this way, which also drops the title, author, comments, form fields, attachments, scripts, and layers.
We ran the same intake record through it. Here’s what pdftotext found in the result:
$ pdftotext intake-redacted.pdf -
# Output: two page-break characters and no text
$ python -c "from pypdf import PdfReader; print(PdfReader('intake-redacted.pdf').metadata)"
{'/Producer': 'pdf-lib (https://github.com/Hopding/pdf-lib)', '/ModDate': '...', '/Creator': 'pdf-lib (https://github.com/Hopding/pdf-lib)', '/CreationDate': '...'}
No text, and no title or author. The only properties left are the library name and the save time, which say nothing about the patient.
Fix 2: Find every copy of the name, not just the first
The second most common failure is simpler. You black out the name on page 1 and miss it in the signature block on page 6.
Don’t hunt by eye. Open Find and redact, type the name, and tick the patterns you need. Emails, phone numbers, SSNs, and card numbers are on by default. Card numbers must pass the Luhn checksum, which filters out most random long numbers. You can limit the search to a page list such as 2-5, 8.
On our test file, that one search found 6 matches across 2 pages: the name twice on page 1, once in the page 2 letter, plus the phone, email, and SSN.

Every match is outlined on the page before anything changes, so you can untick false positives. Then choose Redact selected.
Scanned pages need OCR first
A scan has no text layer, so a normal search finds nothing. Redact PDF reads scanned pages with text recognition on your device. On our scanned referral form, it found the patient name and phone number and tagged both results “OCR”.

That tag matters. Recognition can misread faint or skewed text, so check those pages by eye. Search for variants too: initials, nicknames, and “Reyes, D.” won’t match “Daniel Reyes”.
Fix 3: Make every box cover the whole word
A box that stops one letter short can leave a name guessable. We shrank one box until it clipped “Daniel Reyes”. The tool outlined it in amber and listed it before saving.

Fix it by selecting the box and widening it. Arrow keys move a selected box, and Alt plus the arrow keys resizes it. Hold Shift for bigger steps.
Box width can leak too
The problem is that a box exactly as wide as a short name narrows the guess, especially for readers who know the people involved. Hide word lengths widens every box to a fixed step, so short and long words in that step look the same.

Look at the Notes line in that screenshot. The widened box now clips the word after the name, and the amber outline flags it. Wider boxes trade one leak for another, so recheck the page after turning this on.
Fix 4: Check the saved copy, not the screen
The screen shows what you meant to do. The saved file is what you actually send.
So we tested a mistake on purpose: we left the name in the page 2 letter unticked and saved. The tool reopened the copy and reported it, along with the file name, which still contained the patient’s name.

Here’s the part that catches careful people. We ran pdftotext on that flawed copy:
$ pdftotext -f 2 -l 2 redacted-missed-page-2.pdf -
# Output: one page-break character and no text
Nothing. The name is plainly visible on page 2, but the page is now an image, so extraction finds no text at all. An empty result from a text tool doesn’t prove a page is clean. That’s why the tool also checks the original: every occurrence of a redacted word must sit under a box.
After we ticked the letter, renamed the file to intake-redacted.pdf, and saved again, all four checks passed.
A manual checklist for the copy you send
- Zoom to 400% around every box and look for letter edges.
- Press Ctrl+F and search for each redacted name and number.
- Try selecting and copying text inside a box.
- Run
pdftotext file.pdf - | grep -i "name"if you have it installed. - Check the document properties and the file name.
- Look at every picture, signature, and stamp yourself.
What it costs: file size and searchability
Pages rebuilt as images are bigger than text. These are our measured sizes for the two-page test file:
| Output setting | Page image | File size |
|---|---|---|
| Original (text) | None | 2.0 KB |
| Standard quality, 144 DPI | JPEG, 1224 x 1584 | 85 KB |
| High quality, 200 DPI (default) | JPEG, 1700 x 2200 | 155 KB |
| High quality with Sharp text | PNG, 1700 x 2200 | 85 KB |
| High quality with Keep the rest searchable | JPEG plus invisible text | 161 KB |
The Sharp text result surprised us. Lossless PNG came out smaller than High quality JPEG because plain black-on-white pages compress extremely well, while photos and scans won’t.
Rebuilt pages also lose selectable text. Keep the rest searchable reads each redacted page with OCR and adds the recognized text back, invisibly, outside the boxes. Recognition runs on a copy with the redacted areas already blank, so it never sees what you covered. We confirmed it:
$ pdftotext intake-redacted-searchable.pdf - | grep -i -E "reyes|example.com|6789"
# No output; grep exits with code 1 (no matches)
The rest of the page, such as “reported mild seasonal allergies”, was searchable again.
Court filings and records requests
US federal filings follow Federal Rule of Civil Procedure 5.2, which lets the last four digits of Social Security and account numbers stay visible. Find and redact has an option for exactly that. For FOIA responses, label each box with its exemption code, such as (b)(6) for personal privacy.
For a record of what you removed, download the redaction log. Ours listed counts by page and category, without any redacted text:
Page,Category,Label,Boxes
1,Searched words,,2
1,Phone number,,1
1,Email address,,1
1,Social Security number,,1
2,Searched words,,1
Total,,,6
Courts and agencies set their own rules, so check the ones that apply to you. This guide isn’t legal advice.
How to know it worked
A proper redaction removes the content, catches every occurrence, and passes a check of the file you actually send. Use Redact PDF for the removal and the automatic check, and keep your original until you’ve reviewed the copy.
To confirm it worked, open the saved copy and search for each redacted value. You should find nothing, the tool’s check should show no warnings, and your own look at every page should show only solid boxes where the sensitive details were. For more on keeping documents off other people’s servers while you work, read our guide to browser PDF security for confidential documents.
Frequently asked questions
Is a black rectangle drawn in Word or a PDF editor a safe redaction?
No. The rectangle is drawn on top of the text, and the text stays in the file underneath. In our test, pdftotext printed the covered name, email, and Social Security number from a PDF that looked fully blacked out. Use a tool that removes the content, then check the saved copy.
Does an empty pdftotext result prove a redacted PDF is clean?
No. A page rebuilt as an image has no text to extract, even when a name you meant to redact is plainly visible in the picture. Check the copy against the original, and look at every page yourself.
Can I redact a scanned PDF?
Yes. A scan has no text layer, so search needs text recognition first. Redact PDF reads scanned pages with OCR on your device and labels those results, because recognition can misread faint or skewed text.
Why is the redacted PDF so much bigger than the original?
Redacted pages are stored as images instead of text. Our 2 KB two-page test file became 85 KB at Standard quality and 155 KB at High quality. Sharp text, which saves lossless PNG pages, came out at 85 KB because plain text pages compress well.
Is blurring or pixelating names safer than a black box?
No. Researchers have recovered text from blurred and pixelated images, and tools such as Unredacter automate it. Use solid boxes that remove the content underneath.