Skip to main content
Inspiring
Jul 17, 2023 8:15 AM UTC
Answered

replace highlight with redaction

Is it possible to replace highlighted text with a redaction?

 

My college highligted the text to redact (he only has the reader).

I have to redact all highlights.

I would like to do this all at once instead of going through the whole document.

 

Daniel+SamsonCorrect answer
Participant
Dec 18, 2024 2:44 PM UTC

Are you running this code in Acrobat?

Is the file secured or digitally signed?

 


Thank you again for all of your help!

I was running the code in Acrobat and the file was set to "No security" and not digitally signed.

I had to add the file/folder to my Privileged Locations under Security (Enhanced) and then this worked like a charm.

Cheers!

24 replies

Participant
May 9, 2024 12:30 AM UTC

Hello

 

Total newbie here,

 

i get this in the debugger "NotAllowedError: Security settings prevent access to this property or method.
Doc.applyRedactions:7:Document-Level:Redact" when running

 

this.syncAnnotScan();
var annots = this.getAnnots();
if (annots!=null) {
for (var i in annots) {
var annot = annots[i];
if (annot.type=="Highlight") annot.type = "Redact";
this.applyRedactions();
}
}

 

Could anyone point me to what i need to do to apply the redactions. 

 

 

 

Translate
Bernd Alheit
Community Expert
Community Expert
May 9, 2024 6:06 AM UTC

Use the script in the JavaScript console.
Why do you apply the redactions in the for loop?

Translate
Participant
Jan 11, 2024 1:55 PM UTC

Hi! Is there a way to do the opposite? Redact everything NOT highlighted? I've been searching all over and this is the closest I've found. Sorry to ask a different question.

I'm working with a document that has many lines. And I want to keep say 20 that i've highlighted and redact everything else not highlighted. Or perhaps there is an easier way? 

Translate
try67
Community Expert
Community Expert
Jan 11, 2024 2:06 PM UTC

It's doable, but not a trivial task. You would need to calculate the areas for all the rectangles between the highlights, and then place Redaction annotations over them, and apply them.

Translate
try67
Community Expert
Community Expert
Jul 17, 2023 9:01 AM UTC

Yes, this can be done with a script:

 

this.syncAnnotScan();
var annots = this.getAnnots();
if (annots!=null) {
	for (var i in annots) {
		var annot = annots[i];
		if (annot.type=="Highlight") annot.type = "Redact";
	}
}

 

Translate
Paula5F86Author
Inspiring
Jul 17, 2023 9:05 AM UTC

Thank you!

It works great, but the redactions are in white, and I would like them in black.

Is this possible?

Translate
try67
Community Expert
Community Expert
Jul 17, 2023 9:37 AM UTC

Sure. Change the middle part to this:

 

		if (annot.type=="Highlight") {
			annot.type = "Redact";
			annot.fillColor = color.black;
		}
Translate