Skip to main content
Known Participant
Apr 20, 2017 10:08 AM UTC
Question

Highlight annotation is not getting deleted from Comment list

Hello,

When I delete annotation using PDPageRemoveAnnot method, it deletes the annotation from the page successfully.

But when I look at the comment tab, it still remains there.

Here is my code snipet to find and delete required highlight annotation:

for (int i2 = 0; i2 < PDPageGetNumAnnots(page); i2++) {

  //Get a specific annotation

  annot = PDPageGetAnnot(page, i2);

  if (PDAnnotIsValid(annot)){

  //Determine if the annotation is a Highlight annotation

  if (PDAnnotGetSubtype(annot) == ASAtomFromString("Highlight")) {

  //Create a character pointer to store the annotation's text

  char * annBuf;

  ASInt32 bufSize = PDTextAnnotGetContents(annot, NULL, 0) + 1;

  //Allocate the size of bufSize to the character pointer

  annBuf = (char*)ASmalloc((os_size_t)bufSize);

  //Populate annBuf with the annotation's text

  PDTextAnnotGetContents(annot, annBuf, bufSize);

  //Compare the contents of annBuf with a string

  if (strcmp(annBuf, ident) == 0){

  annotPageNum = i;

  ASFixedRect frect;

  PDAnnotGetRect(annot, &frect);

  PDPageRemoveAnnot(page, PDPageGetAnnotIndex(page, annot));

  break;

  }

  }

  }

}

Can you please help what am missing here?

Thank you in advance!

This topic is closed to new replies. Start a new post to keep the conversation going.

13 replies

Legend
Apr 21, 2017 9:26 AM UTC

Glad to hear it. I hope you also fixed the critical bug I identified.

Translate
Known Participant
Apr 21, 2017 9:58 AM UTC

Yes, Thank you!

Translate
Legend
Apr 21, 2017 6:39 AM UTC

As I said your code may not actually delete all annots  if there is more than one.

Translate
Known Participant
Apr 21, 2017 9:18 AM UTC

Thank you for your help.

I got the solution.

I used :

CosObj cosObj = PDAnnotGetCosObj(annot);

CosObjDestroy(cosObj);

after the PDPageRemoveAnnot() method.

It worked

Translate
lrosenth
Adobe Employee
Adobe Employee
Apr 20, 2017 1:51 PM UTC

PDPageRemoveAnnot() is the correct approach. If the annot isn’t removed from the list, then I would call that a bug n Acrobat/Reader. What version are you using?

Translate
Known Participant
Apr 20, 2017 2:12 PM UTC

I am using 2017 Release (Continuous) | Version 2017.009.20044

I have downloaded it from Acrobat Creative Cloud.

Translate
Legend
Apr 20, 2017 4:59 PM UTC

Now I have time to review your code I can see it will fail badly if there is more than one highlight annotation, because it has the classic bug "sitting on the tree branch to saw it off". Go through the Annots backwards.

Translate
Legend
Apr 20, 2017 1:42 PM UTC

Then it would be best to raise a support case. I believe it is $200 to do this, please let us know if you find out how.

Translate
Known Participant
Apr 20, 2017 12:18 PM UTC

Any updates on this?

Translate
Legend
Apr 20, 2017 1:07 PM UTC

What, after 2 hours??

Translate
Known Participant
Apr 20, 2017 1:29 PM UTC

Sorry, but its urgent!

Translate