Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
2

replace highlight with redaction

Explorer ,
Jul 17, 2023 Jul 17, 2023

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.

 

TOPICS
Edit and convert PDFs , How to
6.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
2 ACCEPTED SOLUTIONS
Community Expert ,
Jul 17, 2023 Jul 17, 2023

Sure. Change the middle part to this:

 

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

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 18, 2024 Dec 18, 2024

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!

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 17, 2023 Jul 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";
	}
}

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 17, 2023 Jul 17, 2023

Thank you!

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

Is this possible?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 17, 2023 Jul 17, 2023

Sure. Change the middle part to this:

 

		if (annot.type=="Highlight") {
			annot.type = "Redact";
			annot.fillColor = color.black;
		}
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 17, 2023 Jul 17, 2023

Thank you, I knew it was simple 🙂

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 09, 2024 Jul 09, 2024

Can you give me step by step on how to do this. 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 23, 2025 Jan 23, 2025
LATEST

This is AWESOME - any way to keep the red "marked for redaction"

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 21, 2023 Oct 21, 2023

Is there any way to actually apply redactions to these after completing the script? Thanks! 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 22, 2023 Oct 22, 2023

Sure, add this line:

 

this.applyRedactions();

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 22, 2023 Oct 22, 2023

Thank you so much! Is there anyway I could also add something in there to redact shapes? I have also been using rectangles to highlight text in images that I would like to redact 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 22, 2023 Oct 22, 2023

If that text is part of the image, you can redact the whole image or nothing. You can, however, edit the image in Photoshop and “redact” manually.

ABAMBO | Hard- and Software Engineer | Photographer
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 22, 2023 Oct 22, 2023

Another question actually - is there a script to redact highlights/shapes after you have flattened the document? 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 22, 2023 Oct 22, 2023

You can redact anything, but you can't use a script to detect highlights or shapes after they were flattened. Only text, or meta-objects (such as comments, fields, links, etc.).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 11, 2024 Jan 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? 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 11, 2024 Jan 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 08, 2024 May 08, 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. 

 

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 08, 2024 May 08, 2024

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 09, 2024 May 09, 2024

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

this.applyRedactions();

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 30, 2024 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 31, 2024 May 31, 2024

Post your full code, please.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 16, 2024 Dec 16, 2024

Also a newbie, but running into a similar situation as described above.

 

Text is still visible on the document and only disappears when I hover over it.  Everything still shows in the Comments pane, but instead of Highlight, they all read "Redact"

 

The code I used was:

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

           annot.fillColor = color.white}

}

this.applyRedactions();}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 16, 2024 Dec 16, 2024

Your code has some issues. Try this:

 

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";
			annot.fillColor = color.white
		}
    }
}
this.applyRedactions();
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 16, 2024 Dec 16, 2024

Thank you for the quick reply!

 

Unfortunately, I am running into the same issue as described above.  All text still appears until I hover over it, all comments changed from Highlight to Redact.  

 

Debugger says: "NotAllowedError: Security settings prevent access to this property or method." (As noted in the top post.)  I have Global Object Security turned off - is there something else I need to do?

 

Thank you again!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 16, 2024 Dec 16, 2024

Are you running this code in Acrobat?

Is the file secured or digitally signed?

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 18, 2024 Dec 18, 2024

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!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines