I have created custom action "TestRemoveAnnotationsFromPage" - which is basically a code example from tutorials, but the only thing it does is to iterate through annotations on a current page, deletes all annotations, saves it and redraws the page. What happens however is, that method "DeleteAnnotation" does not work correctly for me, even though methong "GetAnnotationCount" gets correct number of annotations on page. For ex.: When I create one annotation on the page, it will get count of 1, but it never gets deleted it. When I add another annotation, it deletes the first one, but never the second one, even though the count was 2 this time and so on...
Is there anything I am doing wrong?
My Custom action is:
Code: Select all
if (e.actionName == "TestRemoveAnnotationsFromPage")
{
if (DocuVieware1.GetDocumentType() == GdPicture11.DocumentType.DocumentTypePDF)
{
GdPicture11.GdPicturePDF gdPicturePDF;
//Getting native PDF
if (DocuVieware1.GetNativePDF(out gdPicturePDF) == GdPicture11.GdPictureStatus.OK)
{
//Using an AnnotationManager object to parse PDF annotations
using (GdPicture11.AnnotationManager annotationManager = new GdPicture11.AnnotationManager())
{
if (annotationManager.InitFromGdPicturePDF(gdPicturePDF) == GdPicture11.GdPictureStatus.OK)
{
int annotationCount = annotationManager.GetAnnotationCount();
//Iterating through all annotation
for (int i = 0; i < annotationCount; i++)
{
annotationManager.DeleteAnnotation(i);
}
annotationManager.SaveAnnotationsToPage();
annotationManager.Close();
DocuVieware1.RedrawPage();
}
}
}
}
}