Why Your Redacted PDFs Aren't Actually Redacted (And How to Fix It)
Most PDF redaction tools just draw a black box over text. The data is still there. Here's how content-stream redaction works, how to check a redacted PDF, and how to redact programmatically.
PDF redaction fails more often than it works. A 2022 study found that 65% of PDFs with visual redactions still contained the underlying text in the file. The black box is cosmetic. The data is still there.
You've seen it in the news. A law firm releases court documents with sensitive information "redacted." A journalist opens the PDF, selects the blacked-out text, and pastes it into a text editor. The information is right there.
This isn't a rare edge case. It's the default behavior of most PDF redaction tools.
How PDFs Actually Work
A PDF file is not an image. It's a structured document containing a content stream -- a sequence of operators that tell a PDF renderer what to draw and where.
A text operator looks like this:
BT
/F1 12 Tf
100 700 Td
(John Smith) Tj
ET
This tells the renderer: use font F1 at size 12, move to position (100, 700), and draw the text "John Smith."
When most tools "redact" a PDF, they draw a black rectangle over the text. The rectangle covers it visually. But the text operator is still in the content stream. The text is still there. Anyone can select it, copy it, or extract it programmatically.
The Three Ways PDF Redaction Fails
1. Visual overlay only
The most common failure. A black rectangle is drawn over the text. The underlying text operators are untouched.
How to check: Open the PDF in Chrome. Try to select text in the redacted area. If you can select it, the redaction failed.
2. Metadata not scrubbed
Even if the visible text is removed, the PDF's metadata may still contain sensitive information -- author name, creation date, edit history, comments, and in some cases the original text content.
How to check: Open the PDF in Acrobat or a PDF inspector. Look at Document Properties → Description. Check for comments and annotations.
3. Incorrect layer handling
PDFs can have multiple content layers. A redaction that removes text from one layer may leave it intact on another.
What True PDF Redaction Looks Like
True redaction removes the text at the content stream level.
The process:
- Decompress the content stream (PDFs use FlateDecode compression)
- Tokenize the stream into operators
- Find and remove text operators that match the redaction target
- Recompress the stream
- Draw a black rectangle over the redacted area
- Scrub document metadata
Done correctly, there is no text to select, copy, or extract. The content doesn't exist in the file.
Why Adobe Acrobat's Redaction Is Overkill for Developers
Adobe Acrobat does support true redaction -- it's under Tools → Redact. But it requires a paid Acrobat Pro subscription ($19.99/month), a desktop app, and a manual workflow.
For developers who need to redact documents programmatically at scale -- thousands of PDFs, automated pipelines, serverless functions -- a desktop tool isn't the answer. You need an API.
Redacting PDFs Programmatically with Forme
Forme's redact endpoint finds text by literal string, regex, or preset and redacts it.
Forme removes the matching content from the file rather than covering it: text and images under each redaction, matching text in annotations, links, bookmarks and alternate text, plus XMP metadata, embedded files and document JavaScript. The output is written as a new file, so earlier revisions of the input are not carried over. If a PDF can't be redacted safely (for example, it is encrypted), Forme returns an error instead of a PDF.
Note: Use Forme 0.33.0 or later. Redaction output from earlier versions can still contain the redacted content; if you redacted documents with an earlier version, regenerate them from the originals.
curl -X POST http://localhost:3000/v1/redact \
-H "Authorization: Bearer $FORME_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"pdf": "<base64-encoded-pdf>",
"presets": ["ssn", "email", "phone"],
"patterns": [
{ "pattern": "John Smith", "pattern_type": "Literal" },
{ "pattern": "\\d{3}-\\d{2}-\\d{4}", "pattern_type": "Regex" }
]
}' \
--output redacted.pdf
Built-in presets for common sensitive data
Forme ships with regex presets for the most common PII:
ssn-- Social Security Numbers (xxx-xx-xxxx)email-- Email addressesphone-- US phone numbersdate-of-birth-- Date formats (MM/DD/YYYY, YYYY-MM-DD)credit-card-- 16-digit card numbers
# Redact all common PII in one call
curl -X POST http://localhost:3000/v1/redact \
-H "Authorization: Bearer $FORME_API_KEY" \
-d '{
"pdf": "<base64>",
"presets": ["ssn", "email", "phone", "date-of-birth"]
}'
Text-search redaction
You can also redact by literal string or regex pattern:
import { FormeClient } from '@formepdf/sdk';
const client = new FormeClient({ apiKey: process.env.FORME_API_KEY });
const redacted = await client.redact(pdfBytes, {
patterns: [
{ pattern: 'John Smith', pattern_type: 'Literal' },
{ pattern: '[A-Z]{2}\\d{6}', pattern_type: 'Regex' },
],
presets: ['ssn', 'email'],
});
Redaction templates for recurring workflows
For HIPAA compliance, legal discovery, or financial document processing -- save named redaction templates and reference them by slug:
# Create the template once in the dashboard
# Then reference it by slug on every request:
curl -X POST http://localhost:3000/v1/redact \
-H "Authorization: Bearer $FORME_API_KEY" \
-d '{
"pdf": "<base64>",
"template": "hipaa-patient-record"
}'
Verifying Your PDF Redaction Worked
Selecting text in a viewer only checks what the page shows. It does not check the rest of the file. Check the output with a tool other than the one that redacted it:
- Extract all text with a separate tool (for example
pdftotext redacted.pdf -) and search it for the redacted values. - Check the document properties, bookmarks, comments, and attachments.
- Confirm that the values you did not redact are still there, so you know the check works.
Do not rely on the redaction tool's own search to confirm its result.
Limitations to Know
Forme's text redaction works on text operators in PDF content streams. A few edge cases:
Scanned documents -- If a PDF contains a scanned image with text in it, that image is not modified. Forme redacts text operators, not pixels. For scanned documents you need OCR first.
Text search needs a text mapping -- Search finds text in fonts with a standard encoding or a ToUnicode map (most generated PDFs, including CJK fonts from Chrome and Forme). Text without one can't be found by search; redact it by coordinates.
Whole text runs -- A text run that touches a redaction is removed whole, so a label on the same run (like "SSN:") goes with the match.
Vector graphics -- Lines and shapes under a redaction are covered, not removed.
Encrypted PDFs -- Refused with an error; decrypt them first.
The Compliance Case
For regulated industries -- healthcare, legal, finance, government -- redaction is not optional. HIPAA requires that PHI is actually removed from documents before sharing. A black box overlay does not satisfy the requirement.
The tools most teams reach for -- markup in Acrobat, text boxes in Word, "redacted" overlays in various editors -- produce visually redacted documents that fail a basic copy-paste test.
Real redaction requires removing the content from the file, and checking the result with an independent tool. That is what Forme does, and what the verification steps above check.
Getting Started
# Install the SDK
npm install @formepdf/sdk
# Or call your self-hosted server directly
curl -X POST http://localhost:3000/v1/redact \
-H "Authorization: Bearer $FORME_API_KEY" \
-d '{ "pdf": "<base64>", "presets": ["ssn", "email"] }' \
--output redacted.pdf
Install @formepdf/core -- redactText() and findTextRegions() run the same redaction engine locally, no service required. (Prefer an HTTP endpoint? Redaction also runs on the hosted HTML to PDF API as POST /v1/redact.)
Self-hosting available via the formepdf/forme Docker image for teams that need documents to stay on their own infrastructure.