← Back to blog

How to Redact a PDF Without Adobe

Adobe Acrobat Pro costs $19.99/month and requires a desktop app. Here's how to redact PDFs programmatically and check the result — no Adobe required.

Adobe Acrobat Pro costs $19.99/month and requires a desktop app. For developers who need to redact PDFs programmatically -- in a serverless function, an automated pipeline, or a backend API -- that's not a viable solution.

This guide covers how to redact PDFs programmatically without Adobe, and how to check that the content is really gone.


The Problem with Most PDF Redaction Tools

Most tools that claim to redact PDFs don't actually remove the text. They draw a black rectangle over it. The text is still in the file -- selectable, copyable, and extractable by anyone with a PDF reader or a script.

This includes many online "free PDF redaction" tools, Microsoft Word's PDF export, and basic PDF editors.

To verify: open a "redacted" PDF in Chrome and try to select text in the blacked-out area. If you can select it, the redaction failed.

True redaction removes the text from the PDF content stream entirely. No selection, no extraction, nothing there.


What Adobe Acrobat's Redaction Actually Does

Adobe Acrobat Pro does support true redaction -- it's under Tools → Redact. It removes text from the content stream and scrubs metadata.

But it has significant limitations for developers:

  • Requires a paid Acrobat Pro subscription ($19.99/month)
  • Desktop-only -- no API, no automation
  • Manual workflow -- you mark regions by hand
  • No programmatic access to redaction logic
  • Can't be called from Node.js, Python, or any backend

If you need to redact one PDF occasionally, Acrobat works. If you need to redact hundreds of PDFs automatically, you need an API.


Option 1: Forme API

Forme's redact endpoint redacts by coordinates, text pattern, or preset with a single HTTP call. Works from any language, any environment.

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.

Basic redaction by coordinates

curl -X POST http://localhost:3000/v1/redact \
  -H "Authorization: Bearer $FORME_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "pdf": "<base64-encoded-pdf>",
    "redactions": [
      { "page": 0, "x": 100, "y": 150, "width": 200, "height": 20 }
    ]
  }' \
  --output redacted.pdf

Text-search redaction

Find and redact text by string or regex pattern -- no need to know coordinates:

curl -X POST http://localhost:3000/v1/redact \
  -H "Authorization: Bearer $FORME_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "pdf": "<base64-encoded-pdf>",
    "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 PII

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", "date-of-birth"]
  }' \
  --output redacted.pdf

Available presets:

  • ssn -- Social Security Numbers
  • email -- Email addresses
  • phone -- US phone numbers
  • date-of-birth -- Common date formats
  • credit-card -- 16-digit card numbers

In Node.js

import { FormeClient } from '@formepdf/sdk';
import { readFileSync, writeFileSync } from 'fs';

const client = new FormeClient({
  apiKey: process.env.FORME_API_KEY
});

const pdf = readFileSync('document.pdf');

const redacted = await client.redact(pdf, {
  presets: ['ssn', 'email'],
  patterns: [
    { pattern: 'John Smith', pattern_type: 'Literal' }
  ],
});

writeFileSync('redacted.pdf', redacted);

In Python

import formepdf
import base64

client = formepdf.FormeClient(api_key="your_api_key")

with open("document.pdf", "rb") as f:
    pdf_bytes = f.read()

redacted = client.redact(
    pdf=pdf_bytes,
    presets=["ssn", "email"],
    patterns=[
        {"pattern": "John Smith", "pattern_type": "Literal"}
    ]
)

with open("redacted.pdf", "wb") as f:
    f.write(redacted)

Option 2: Self-Hosted

If your documents can't leave your infrastructure, Forme ships as a Docker image with the same redaction API running on your own servers:

docker pull formepdf/forme:0.33.0
docker run -p 3000:3000 formepdf/forme:0.33.0

Then call it the same way:

curl -X POST http://localhost:3000/v1/redact \
  -H "Content-Type: application/json" \
  -d '{
    "pdf": "<base64>",
    "presets": ["ssn", "email"]
  }' \
  --output redacted.pdf

No API key required for self-hosted. No data leaves your infrastructure. Ideal for healthcare, legal, and government use cases.


Metadata

PDFs store metadata -- author name, creation date, edit history, software used, and sometimes content from earlier versions. This metadata survives a visual overlay redaction. Forme removes XMP metadata and replaces the document information on every redaction (/Producer becomes "Forme"). Whatever tool you use, check the document properties of the output as well as the page.


Verifying Your Redaction

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:

  1. Extract all text with a separate tool (for example pdftotext redacted.pdf -) and search it for the redacted values.
  2. Check the document properties, bookmarks, comments, and attachments.
  3. 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

Scanned documents -- If a PDF is a scanned image, there are no text operators to remove. You need OCR first to make the text machine-readable before redacting it.

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.


Getting Started

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.)

npm install @formepdf/sdk
import { FormeClient } from '@formepdf/sdk';

const client = new FormeClient({
  apiKey: process.env.FORME_API_KEY
});

const redacted = await client.redact(pdfBytes, {
  presets: ['ssn', 'email', 'phone'],
});

Self-hosting available via formepdf/forme Docker image for teams that need documents to stay on their own infrastructure.