Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
Any updates on this?
Copy link to clipboard
Copied
What, after 2 hours??
Copy link to clipboard
Copied
Sorry, but its urgent!
Copy link to clipboard
Copied
In that case you need to pay somebody to solve your problem. The people you meet here in the forums are volunteering their time. We are not getting paid to help you with your problems, and we can therefore only do that once everything else is taken care of: Eating, sleeping, family, earning a living, ...
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
I am using 2017 Release (Continuous) | Version 2017.009.20044
I have downloaded it from Acrobat Creative Cloud.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Hello Irosenth,
As you said, PDPageRemoveAnnot() is the correct approach. Comments are still there in comment list.
When I click on that comment box, the border area of the annotation that was deleted is highlighted.
Thanks
Copy link to clipboard
Copied
As I said your code may not actually delete all annots if there is more than one.
Copy link to clipboard
Copied
Thank you for your help.
I got the solution.
I used :
CosObj cosObj = PDAnnotGetCosObj(annot);
CosObjDestroy(cosObj);
after the PDPageRemoveAnnot() method.
It worked
Copy link to clipboard
Copied
Glad to hear it. I hope you also fixed the critical bug I identified.
Copy link to clipboard
Copied
Yes, Thank you!