Skip to main content
Participant
October 8, 2021
Answered

Delete Empty Comments with a Script

  • October 8, 2021
  • 2 replies
  • 572 views

Dear all, hope you are good and safe, 

could someone help me with the following?

after making a markup PDF with many comments, I want to run a script to search and delete just the empty comments (empty sticky notes, rectangles, circles). what I found until now is the following, but this removes everything.

 

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

 

 

This topic has been closed for replies.
Correct answer try67

What do you mean by "empty", exactly? No attached comment text? If so, you can do it by changing this:

annots[i].destroy();

To this:

if (annots[i].contents=="") annots[i].destroy();

 

2 replies

Participant
October 10, 2021

Amazing! thanks so much!

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
October 9, 2021

What do you mean by "empty", exactly? No attached comment text? If so, you can do it by changing this:

annots[i].destroy();

To this:

if (annots[i].contents=="") annots[i].destroy();