Skip to main content
POST /v1/redact Redact sensitive content in a PDF by coordinates, text pattern, regex, preset, or saved template. Matching content is removed from the file, not only covered with a black box.
Use Forme 0.34.0 or later (server image formepdf/forme:0.34.0) for redaction. Output from earlier versions can still contain the redacted content. If you redacted documents with an earlier version, regenerate them from the originals: see Redaction.
This page documents the self-hosted server. For the hosted API at https://api.formepdf.com, see Hosted API — Redact.

Request Body

At least one of redactions, patterns, presets, or template is required. All can be combined in a single request — patterns from all sources are merged.

Coordinate Redaction

Redact specific rectangular regions by page coordinates. Region coordinates are in points on the page as displayed: x and y are measured from the top-left corner of the visible area (the CropBox), after the page’s /Rotate is applied. These are the coordinates a PDF viewer shows, and the ones findTextRegions returns. RedactionRegion fields:

Text Pattern Redaction

Find and redact text by literal string or regular expression. RedactionPattern fields:

Presets

Built-in patterns for common sensitive data types. Pass an array of preset names:

Redaction Templates

On the hosted API, reference a saved redaction template by slug:
Combine a template with additional inline patterns — all sources are merged:
Redaction templates require the hosted API. Self-hosted users should pass patterns and presets directly.

Response

200 OK with Content-Type: application/pdf — the redacted PDF.

What Redaction Does

  • Page content: Text and images under a redacted region are removed from the page. Lines, shapes, and clipping paths are cut at the region’s edges.
  • Hidden copies: Matching text is removed from annotations, links, bookmarks, and alternate text.
  • Document data: XMP metadata, embedded files, and document JavaScript are removed. The document information is replaced (/Producer is “Forme”).
  • New file: The output is written as a new file that holds only the content the document still uses. Earlier revisions of the input are not carried over.
  • Visual overlay: A black rectangle covers each redacted area.
If the input cannot be redacted safely, the request fails with 422 and code REDACTION_REFUSED instead of returning a PDF. See Known Limitations.
To check the result, see Verifying redaction. Selecting text in a viewer is not enough.

Known Limitations

  • Whole text runs: A text run is removed whole when any of its glyphs is under a region: at least a fifth of the glyph’s box lies under the region in each direction, or the centre of the box does. A glyph that is more than 80% outside the region along one axis, with its centre outside, stays. If the match shares a run with other words (for example a label on the same line), those words are removed too.
  • Images: An image under a region is removed whole, even where most of it lies outside the region. Text inside an image is not searchable; run OCR first.
  • Vector graphics: Paths under a region are cut at the region’s edges. Curves in a cut path are redrawn as fine straight segments (within 0.05 pt).
  • Text search needs a text mapping: Search finds text in fonts with a standard encoding or a ToUnicode map. Text without one cannot be found by search — use coordinate redaction.
  • Refused input: These return an error instead of a PDF:
    • encrypted PDFs;
    • form fields under a region or holding matching text;
    • text, images, or paths inside a form XObject under a region;
    • an area painted with a tiling pattern under a region;
    • text drawn with a Type3 font that may lie under a region (including a Type3 font whose glyph bounds are unknown, anywhere on a page with a region);
    • text used as a clipping path (rendering modes 4 to 7) under a region;
    • a page whose /Rotate is not a multiple of 90, or that sets /UserUnit, when it has a region;
    • a region with a coordinate that is not a finite number.
  • Maximum 50 patterns per request: Keep the total number of patterns (including those expanded from presets and templates) under 50.

  • Redaction — how Forme redaction works, compliance use cases
  • Redaction Templates — creating and managing saved templates on the hosted API