Firstly I am unfortunately not a coder. So i suspect that some of this is probably glaring obvious to you all. I provide legal support to a team of lawyers. They often need PDFs redacted and they usually highlight what they need redacted and I use Adobe's redact tool. I have a snippet of code that will convert highlights to redactions but it only works on OCR'd text. What I would like to be able to do is convert the rectangle annotation to a redaction.
This is what I have so far:
var annots = this.getAnnots();
var rct = getAnnots(this.pageNum)[0].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] ];
for (var i=annots.length-1; i>=0; i--) {
if (annots[i].type == "Square") {
this.addAnnot( {
page: annots[i].page,
type: "Redact",
quads: qd,
overlayText: "REDACTED",
alignment: true,
fillColor: color.black,
textColor: color.white,
textSize: 0,
});
}
}
this.applyRedactions ({
bKeepMarks: false,
bShowConfirmation: false,
});
It works for the first rectangle annoation, but doesnt loop for every rectangle annotation. I know that i need to add this part:
var rct = getAnnots(this.pageNum)[0].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] ];
into the For statement, but I cant figure out how. Any help would be appreciated
Ok thanks to Bernd (from the adobe forum) I have managed to get this to work. So for everyone else who might find this helpful here is the code