Skip to main content
Inspiring
July 17, 2023
Answered

replace highlight with redaction

  • July 17, 2023
  • 3 replies
  • 5973 views

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.

 

Correct answer beth_8171

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!

3 replies

Participant
May 9, 2024

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. 

 

 

 

try67
Community Expert
Community Expert
May 9, 2024

Move this line to be the last one in your code:

this.applyRedactions();

Participant
May 30, 2024

I have add:

this.applyRedactions();

But does not apply the redactions. Text text is still visible, but only redacts if I hover over. I wanting to redact what is highlighted and save the file as redacted version.

Participant
January 11, 2024

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? 

try67
Community Expert
Community Expert
January 11, 2024

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.

try67
Community Expert
Community Expert
July 17, 2023

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";
	}
}

 

Paula5F86Author
Inspiring
July 17, 2023

Thank you!

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

Is this possible?

try67
Community Expert
Community Expert
July 17, 2023

Sure. Change the middle part to this:

 

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