Copy link to clipboard
Copied
I'm having a weird issue with my script. I want to create a rectangle annotation (the one found in Comments > then the square icon in the ribbon, NOT a text box). I set it to full page. If I have the code below without the for loop and just manually set p to a number, it creates the rectangle at the page corresponding to the number as expected. It also shows up in the comments section with all the correct properties set by the script (author, content, etc).
Now I wanted to automate it to do this to all pages in the document by using a For loop for p. However, it only creates the rectangle but none of the properties are applied and therefore Acrobat doesn't consider it a markup and I can't redact it because it doesn't show up in the Comment section as a markup. Is there a way around this or is my code just messed up?
var re = /.*\/|\.pdf$/ig;
var FileNM = this.path.replace(re,"");
var Path = this.path;
for (var p = 0; p < this.numPages; p++) {
var aRect = this.getPageBox("Crop",p);
var LeftPoint = aRect[0]
var TopPoint = aRect[1]
var RightPoint = aRect[2]
var BottomPoint = aRect[3]
var annot = this.addAnnot({ page: p, type: "Square", rect: [LeftPoint, TopPoint, RightPoint, BottomPoint], name: "Test", author: "Redact", contents: "Redaction",});
}
this.flattenPages()
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Remove the line
this.flattenPages();
Copy link to clipboard
Copied
Omg. Thanks. I can't believe I missed that. Second Pair of eyes helped. Have a good one.

