Skip to main content
Known Participant
April 20, 2017
Question

Highlight annotation is not getting deleted from Comment list

  • April 20, 2017
  • 5 replies
  • 1398 views

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 has been closed for replies.

5 replies

Legend
April 21, 2017

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

Known Participant
April 21, 2017

Yes, Thank you!

Legend
April 21, 2017

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

Known Participant
April 21, 2017

Thank you for your help.

I got the solution.

I used :

CosObj cosObj = PDAnnotGetCosObj(annot);

CosObjDestroy(cosObj);

after the PDPageRemoveAnnot() method.

It worked

lrosenth
Adobe Employee
Adobe Employee
April 20, 2017

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?

Known Participant
April 20, 2017

I am using 2017 Release (Continuous) | Version 2017.009.20044

I have downloaded it from Acrobat Creative Cloud.

Legend
April 20, 2017

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.

Legend
April 20, 2017

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.

Known Participant
April 20, 2017

Any updates on this?

Legend
April 20, 2017

What, after 2 hours??

Known Participant
April 20, 2017

Sorry, but its urgent!