Skip to main content
Participant
February 28, 2020
Answered

How to Delete all the comments from a PDF File

  • February 28, 2020
  • 3 replies
  • 13315 views
Can somebody help to know if there is a way to delete all the comments from a PDF in a single go?
 
I have some 1000+ PDFs, those have too many comments, i want to delete it in 1 go for each file.
 
May be i can try building a bot for that after then.
 
Please help
 
Thanks in advance
Correct answer try67

This code will remove all the comments from a file:

 

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

 

If you have Acrobat Pro you can use it in an Action and process multiple files in a single process.

 

3 replies

Participant
May 28, 2025

If you don't have Acrobat Pro, you can use a cheap 3rd party tool called BatchPurifier to remove comments from multiple PDF files in batch.

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
February 28, 2020

This code will remove all the comments from a file:

 

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

 

If you have Acrobat Pro you can use it in an Action and process multiple files in a single process.

 

Participant
June 10, 2022

I went to 1. More Tools - and found the "Action Wizard" and opened it up for the doc I am working on.  2. At the top of the page I found "New Action" and chose that.  Once the box opened on the right side I chose the circle with a cross (new action) and did a cut and paste of the code above there.  NOTHING HAPPENED. 

So I tried a second route. 1. I went to the top of the page and chose "New Custom Command" 2. once the box popped up I scrolled down and chose "Execute JavaScript"  3.  When the box popped up I did a cut and past of the code in there.  NOTHING HAPPENED.  So I am not sure where you are posting this script but I have spent far too long trying to fix this document that I needed to submit yesterday!  So frustrating.

try67
Community Expert
Community Expert
June 10, 2022

Did you add a Save command?

Inspiring
February 28, 2020

That's possible using JavaScript and can be automated with Acrobat. I know that code that does this has been posted in these and other forums, but post again if you can't find anything with a search.