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
redactremoves the content under the region from the file: see Redact content.stamp-imagestretches one black pixel over the region, andstamp-textmarks every page: seestamp-imageandstamp-text.redactrewrites the whole file, so no earlier revision keeps the removed content.optimizethen shrinks it: see Optimize a PDF.
Variations
- Several regions or pages: list more entries in
regions. - Drop whole pages: add a
deletestage. - The metadata names the author: a
set-metadatastage overwrites the fields you give, and keeps the others.