Skip to main content
Version: 9.x

Redact content

Removes text and images from a PDF for good, not just from view.

POST/forms/pdf/redact
filesfile[]required

The PDFs.

archivesfile[]

ZIP files Gotenberg unpacks: each entry counts as a file uploaded under files.

URLs Gotenberg downloads first, as if you had uploaded the files. Each entry takes a url, and optionally extraHttpHeaders.

regionslistrequired

Rectangles with a page, and x, y, width and height in points from the bottom-left corner.

The PDF, or a ZIP of the PDFs when you send several.

The route also takes the headers. An error answers a status and a message: see Errors.

Redact a region​

curl \
--request POST http://localhost:3000/forms/pdf/redact \
--form files=@report.pdf \
--form 'regions=[
{ "page": 1, "x": 160, "y": 435, "width": 60, "height": 25 }
]' \
-o report.pdf

Gotenberg removes the content under each region from the file itself: the "Page 1" label is gone from the page and from any text a reader or a script extracts. Nothing is drawn in its place.

Measure the region​

A region's x, y, width and height count in points from the bottom-left corner of the page, 72 points to the inch. The pages of this report measure 446 by 631 points, and its label sits about 440 points up from the bottom.

Mark the redaction​

Stamp a black box over the region to show where content was. A one-pixel black PNG stretches to the size you give it:

curl \
--request POST http://localhost:3000/forms/pdf/pipe \
--form files=@report.pdf \
--form files=@black.png \
--form 'stages=[
{ "op": "redact", "regions": [ { "page": 1, "x": 160, "y": 435, "width": 60, "height": 25 } ] },
{ "op": "stamp-image", "image": "black.png", "pages": "1", "x": 160, "y": 435, "width": 60, "height": 25 }
]' \
-o report.pdf

Redact first: a stamp only covers what's under it.

In a list of stages​

The stage also runs in a list on /forms/pdf/pipe, and on the PDFs a Chromium or LibreOffice conversion makes, in its stages field:

curl \
--request POST http://localhost:3000/forms/pdf/pipe \
--form files=@report.pdf \
--form 'stages=[
{ "op": "redact", "regions": [ { "page": 1, "x": 100, "y": 420, "width": 250, "height": 60 } ] }
]' \
-o report.pdf