Remove highlighting and comments from a PDF file

In Acrobat Pro (I’m using Adobe Acrobat Pro DC), Tools>Action wizard>New action>More tools>Execute javascript>Specify settings>Create and edit JS:

Add the following code:

/* Remove Highlighting only */
this.syncAnnotScan();
var annots = this.getAnnots();
if (annots!=null) {
for (var i=annots.length-1; i>=0; i--) {
if (annots[i].type=="Highlight")
annots[i].destroy();
}
}

or if you want to remove both highlighting and comments:

/* Remove Highlighting and Comments */
this.syncAnnotScan();
var annots = this.getAnnots();
if (annots!=null) {
for (var i=annots.length-1; i>=0; i--) {
annots[i].destroy();
}
}

You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.