Redactions#
Creating Redactions#
Redactions can be created with the Redact type annotation.
The defined rectangle for the annotation defines the area to redact. If this area touches document text then any letters it touches will be completely removed.
Applying a Redaction#
Once a redaction has been created it will not commit the redaction to the document area until it is applied.
The following example creates a redaction area on the page and then applies the redaction, with options to paint the redacted area in black, and then saves the result as a new file.
EXAMPLE
let fileData = fs.readFileSync("test.pdf")
let document = mupdf.Document.openDocument(fileData, "application/pdf")
let page = document.loadPage(0)
let annotation = page.createAnnotation("Redact")
annotation.setRect([40, 40, 300, 20])
annotation.applyRedaction(true)
fs.writeFileSync("output-redact.pdf", document.saveToBuffer("incremental").asUint8Array())
You can also apply all the current redaction annotations on a page at the page-level with:
EXAMPLE
page.applyRedactions()