Copy link to clipboard
Copied
Hello everyone,
I am attempting to autmate parts of my PDF redacting process by using the following javascript code to draw redactions inside manually drawn redaction marks:
var annots = this.getAnnots();
for (var i=annots.length-1; i>=0; i--) {
if (annots[i].type == "Square") {
var rct = annots[i].rect;
var left = rct[0];
var right = rct[2];
var top = rct[3];
var bot = rct[1];
var qd = [ [left, top, right, top, left, bot, right, bot] ];
this.addAnnot( {
page: annots[i].page,
type: "Redact",
quads: qd,
overlayText: " ", //THIS IS THE REDACTION TEXT
alignment: 1, // "0" = LEFT, "1" = CENTRE, "2" = RIGHT
fillColor: color.white, //THIS CHANGES THE FILL COLOUR
textColor: color.white, //THIS CHANGES THE FONT COLOUR
textSize: 0, //FONT SIZE, '0' will adjust the size to fit each box, otherwise you can use a specific font size
});
}
}
this.applyRedactions ({
bKeepMarks: false,
bShowConfirmation: false,
});
Source:
The code works, but my organization has sylistic standards that require redaction marks to apear like brackets "[ ]", or perhaps like a rectangular shape with four corners and the sides hidden. These redaction marks must be visible in the final PDF.
Can anyone help me use javascript, or some other means to make the rectangles appear like brackets? The following code uses a dashed border to produce something similar to brackets, but I would prefer a better solution:
Before:
var annots = this.getAnnots();
for (var i = 0; i < annots.length; i++) {
if (annots[i].type == "Square") {
annots[i].strokeColor = color.black;
annots[i].dash = [60,20];
}
}
Result:
Thank you!!!
Copy link to clipboard
Copied
Redacted areas are replaced by text or a rectangle. These are setting in both the redaction tool, and on the actual redaction annotation. You could set the overlay text to be brackets.
Here's the reference entry.
https://opensource.adobe.com/dc-acrobat-sdk-docs/library/jsapiref/JS_API_AcroJS.html#overlaytext
Or if setting the overlay text doesn't work, then brackets or corner symbols could be drawn using the "ink" annotation. But, this would need to be done after the document is redacted. If done before redaction, the drawing could be removed. So, your automation script will need to save the redaction rectangle, apply the redaction, then create the brackets, and finally flatten.
Here's an article on automating Redaction:
https://acrobatusers.com/tutorials/auto_redaction_with_javascript/
Copy link to clipboard
Copied
Much appreciated, Thom! I will try these suggestions and see how it goes.