Skip to main content
Version: 9.x

Publish a redacted copy

You have a report with a detail you can't share. You want a public copy with that detail gone for good, a black box where it was, a mark that says the copy is redacted, and a small file.

Request​

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 },
{ "op": "stamp-text", "text": "REDACTED COPY", "x": 36, "y": 36, "fontSize": 10, "color": "#b42318" },
{ "op": "optimize" }
]' \
-o report-public.pdf

Result​

Page 1 no longer holds its label, in its pages or in any text a script extracts. A black box covers its place, and every page says "REDACTED COPY" at the bottom left.

How it works​

  • redact removes the content under the region from the file: see Redact content.
  • stamp-image stretches one black pixel over the region, and stamp-text marks every page: see stamp-image and stamp-text.
  • redact rewrites the whole file, so no earlier revision keeps the removed content. optimize then shrinks it: see Optimize a PDF.

Variations​

  • Several regions or pages: list more entries in regions.
  • Drop whole pages: add a delete stage.
  • The metadata names the author: a set-metadata stage overwrites the fields you give, and keeps the others.