GdPicture.NET.14.API
GdPicture14 Namespace / AnnotationManager Class / DeleteAnnotation Method
The 0-based index of the required annotation within the selected page of the handled document. It must be a value from 0 to AnnotationManager.GetAnnotationCount-1.
Example





In This Topic
DeleteAnnotation Method (AnnotationManager)
In This Topic
Removes a required GdPicture/XMP annotation object specified by its index related to the selected page of the document currently handled by this AnnotationManager object.

Be aware that this method only handles GdPicture/XMP annotations. Likewise, annotations are always treated relative to the selected page.

Syntax
'Declaration
 
Public Function DeleteAnnotation( _
   ByVal AnnotationIdx As Integer _
) As GdPictureStatus
public GdPictureStatus DeleteAnnotation( 
   int AnnotationIdx
)
public function DeleteAnnotation( 
    AnnotationIdx: Integer
): GdPictureStatus; 
public function DeleteAnnotation( 
   AnnotationIdx : int
) : GdPictureStatus;
public: GdPictureStatus DeleteAnnotation( 
   int AnnotationIdx
) 
public:
GdPictureStatus DeleteAnnotation( 
   int AnnotationIdx
) 

Parameters

AnnotationIdx
The 0-based index of the required annotation within the selected page of the handled document. It must be a value from 0 to AnnotationManager.GetAnnotationCount-1.

Return Value

A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK. We strongly recommend always checking this status first.
Remarks
It is recommend to use the AnnotationManager.GetStat method to identify the specific reason for the method's failure, if any.

Please ensure that you have selected the proper page before starting any annotation related action with the handled document. Annotations are always treated relative to the currently selected page.

Example
How to delete the specified annotation.
This example shows you how to delete all GdPicture/XMP annotations contained on the selected page.
'We assume that the GdViewer1 control has been integrated into your application.
Dim oAnnotationManager As AnnotationManager = GdViewer1.GetAnnotationManager()
Dim status As GdPictureStatus = oAnnotationManager.SelectPage(GdViewer1.CurrentPage)
If status = GdPictureStatus.OK Then
    Dim annotCount As Integer = oAnnotationManager.GetAnnotationCount()
    For i As Integer = 1 To annotCount
        status = oAnnotationManager.DeleteAnnotation(0)
        If status <> GdPictureStatus.OK Then Exit For
    Next
End If
MessageBox.Show("Done!  Status: " + status.ToString(), "AnnotationManager.DeleteAnnotation")
//We assume that the GdViewer1 control has been integrated into your application.
AnnotationManager oAnnotationManager = GdViewer1.GetAnnotationManager();
GdPictureStatus status = oAnnotationManager.SelectPage(GdViewer1.CurrentPage);
if (status == GdPictureStatus.OK)
{
    int annotCount = oAnnotationManager.GetAnnotationCount();
    for (int i = 1; i <= annotCount; i++)
    {
        status = oAnnotationManager.DeleteAnnotation(0);
        if (status != GdPictureStatus.OK)
            break;
    }
}
MessageBox.Show("Done!  Status: " + status.ToString(), "AnnotationManager.DeleteAnnotation");
This example explains you how to delete the annotation specified by its index.
Using annotationManager As AnnotationManager = New AnnotationManager()
    If annotationManager.InitFromFile("source.pdf") = GdPictureStatus.OK Then
        For p As Integer = 1 To annotationManager.PageCount
            If annotationManager.SelectPage(p) = GdPictureStatus.OK Then
                Dim annotCount As Integer = annotationManager.GetAnnotationCount()
                If annotationManager.GetStat() = GdPictureStatus.OK Then
                    For a As Integer = 0 To annotCount - 1
                        Dim value As Object = annotationManager.GetAnnotationPropertyValue(a, "Tag")
                        Dim tagValue As String = ""
                        If value IsNot Nothing Then
                            tagValue = CStr(value)
                            If tagValue.Equals("delete") Then
                                If annotationManager.DeleteAnnotation(a) <> GdPictureStatus.OK Then Exit For
                            Else
                                tagValue += " checked"
                                value = CObj(tagValue)
                                If annotationManager.SetAnnotationPropertyValue(a, "Tag", value) <> GdPictureStatus.OK Then Exit For
                            End If
                        End If
                    Next
                    If annotationManager.GetStat() = GdPictureStatus.OK Then annotationManager.SaveAnnotationsToPage()
                    If annotationManager.GetStat() <> GdPictureStatus.OK Then Exit For
                Else
                    Exit For
                End If
            Else
                Exit For
            End If
        Next
        If annotationManager.GetStat() = GdPictureStatus.OK Then
            If annotationManager.SaveDocumentToPDF("dest.pdf") = GdPictureStatus.OK Then
                MessageBox.Show("Done!", "AnnotationManager.DeleteAnnotation")
            Else
                MessageBox.Show("The document can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.DeleteAnnotation")
            End If
        Else
            MessageBox.Show("Error!   Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.DeleteAnnotation")
        End If
        annotationManager.Close()
    Else
        MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.DeleteAnnotation")
    End If
End Using
using (AnnotationManager annotationManager = new AnnotationManager())
{
    if (annotationManager.InitFromFile("source.pdf") == GdPictureStatus.OK)
    {
        for (int p = 1; p <= annotationManager.PageCount; p++)
        {
            if (annotationManager.SelectPage(p) == GdPictureStatus.OK)
            {
                int annotCount = annotationManager.GetAnnotationCount();
                if (annotationManager.GetStat() == GdPictureStatus.OK)
                {
                    for (int a = 0; a < annotCount; a++)
                    {
                        object value = annotationManager.GetAnnotationPropertyValue(a, "Tag");
                        string tagValue = "";
                        if (value != null)
                        {
                            tagValue = (string)value;
                            if (tagValue.Equals("delete"))
                            {
                                if (annotationManager.DeleteAnnotation(a) != GdPictureStatus.OK) break;
                            }
                            else
                            {
                                tagValue += " checked";
                                value = (object)tagValue;
                                if (annotationManager.SetAnnotationPropertyValue(a, "Tag", value) != GdPictureStatus.OK) break;
                            }
                        }
                    }
                    if (annotationManager.GetStat() == GdPictureStatus.OK)
                        annotationManager.SaveAnnotationsToPage();
                    if (annotationManager.GetStat() != GdPictureStatus.OK) break;
                }
                else break;
            }
            else break;
        }
        if (annotationManager.GetStat() == GdPictureStatus.OK)
        {
            if (annotationManager.SaveDocumentToPDF("dest.pdf") == GdPictureStatus.OK)
                MessageBox.Show("Done!", "AnnotationManager.DeleteAnnotation");
            else
                MessageBox.Show("The document can't be saved. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.DeleteAnnotation");
        }
        else
            MessageBox.Show("Error!   Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.DeleteAnnotation");
        annotationManager.Close();
    }
    else
        MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.DeleteAnnotation");
}
See Also