Redact content
Removes text and images from a PDF for good, not just from view.
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