Javascript to change annotation types in Acrobat

Using javascript posted here by Evermap, and copied below you can automatically transform annotations from one type in Adobe Acrobat to another type. It will not only allow you to convert highlights, underlined text, and crossed out text, but also to change from proposed redactions to any one of these annotations - but not vice versa.


In order to add the script to a new action in Acrobat, select the Action Wizard tool and then click on 'New Action', and choose 'Execute JavaScript' from the 'More Tools' drop down menu.




Click on 'Specify Settings' and enter the script in the editor. Set the type you want to find on the first highlighted line in the below screen grab, and the type you want to add in on the second line. If you want to reference crossed out text use the type, 'CrossOut'.



Uncheck the 'Prompt User' box, and then add the Save step to the action, so you will not be prompted to save each file when the action runs.




After saving and running the action, you can process multiple files by selecting the options in the drop down menu to add files or an entire folder.




The script can be used to convert multiple proposed redactions in multiple PDF files like this:




The script will convert one or more lines of continuous text selected for a redaction, but it will not convert a large block of text set for redaction.



The action will give this result:







You can add a second javascript to the same action to specify the highlighting color you want the action to convert annotations or proposed redactions to:


this.syncAnnotScan();

var annots = this.getAnnots();


for (var i = 0; i < annots.length; i++) {

if (annots[i].type == "Highlight") {

annots[i].strokeColor = color.yellow;

}

}







try

{

this.syncAnnotScan();

for (var nPage = 0; nPage < this.numPages; nPage++)

{

// get all annotations on the page

var Annots = this.getAnnots({

nPage:nPage

});

// process each annotation

if (Annots != null)

{

for (var i = 0; i < Annots.length; i++)

{

if (Annots[i].type == "StrikeOut")

{

Annots[i].type = "Highlight";

}

}

}

}

}

catch(e)

{

app.alert(e);

}