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
GdPicture14 Namespace / AnnotationManager Class / GetFirstAnnotationCommentIdx Method

GetFirstAnnotationCommentIdx Method (AnnotationManager)

In This Topic
Returns an index of the first GdPicture/XMP comment annotation, if any exists, that is attached to a 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 GetFirstAnnotationCommentIdx( _
   ByVal AnnotationIdx As Integer _
) As Integer
public int GetFirstAnnotationCommentIdx( 
   int AnnotationIdx
)
public function GetFirstAnnotationCommentIdx( 
    AnnotationIdx: Integer
): Integer; 
public function GetFirstAnnotationCommentIdx( 
   AnnotationIdx : int
) : int;
public: int GetFirstAnnotationCommentIdx( 
   int AnnotationIdx
) 
public:
int GetFirstAnnotationCommentIdx( 
   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

An index of the first GdPicture/XMP comment annotation, if exists, that is attached to the GdPicture/XMP annotation according to the given index. The AnnotationManager.GetStat method can be subsequently used to determine if this method has been successful.

The returned value is between 0 and AnnotationManager.GetAnnotationCount-1 if the annotation with the given index includes a comment annotation, or -1 if no comment annotation is attached to the given annotation.

Remarks
Please ensure that the returned value is valid annotation index, which means it is greater then -1, before using it further.

Be aware that annotations are always treated relative to the selected page.

Example
How to find out the first comment of the specified annotation, if some comments are attached.
Using annotationManager As AnnotationManager = New AnnotationManager()
    If (annotationManager.InitFromFile("source.pdf") = GdPictureStatus.OK) AndAlso
       (annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) Then
        Dim annotCount As Integer = annotationManager.GetAnnotationCount()
        Dim annot As GdPicture14.Annotations.Annotation = Nothing
        Dim comment As GdPicture14.Annotations.AnnotationComment = Nothing
        For a As Integer = 0 To annotCount - 1
            annot = annotationManager.GetAnnotationFromIdx(a)
            If annot IsNot Nothing Then
                Dim annotType As GdPicture14.Annotations.Annotation.GdPictureAnnotationType = annotationManager.GetAnnotationType(a)
                Dim commentIdx As Integer = annotationManager.GetFirstAnnotationCommentIdx(a)
                If (annotationManager.GetStat() = GdPictureStatus.OK) AndAlso (commentIdx > -1) Then
                    comment = CType(annotationManager.GetAnnotationFromIdx(commentIdx), GdPicture14.Annotations.AnnotationComment)
                    If comment IsNot Nothing Then
                        MessageBox.Show("The type of the annotation with comment: " + annotType + vbCrLf + "The first comment:" + vbCrLf + comment.Text, "AnnotationManager.GetFirstAnnotationCommentIdx")
                    Else
                        MessageBox.Show("Something goes wrong.", "AnnotationManager.GetFirstAnnotationCommentIdx")
                    End If
                'Else This annotation does not include any comment.
                End If
            Else
                MessageBox.Show("Something goes wrong.", "AnnotationManager.GetFirstAnnotationCommentIdx")
            End If
        Next
        annotationManager.Close()
    Else
        MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.GetFirstAnnotationCommentIdx")
    End If
End Using
using (AnnotationManager annotationManager = new AnnotationManager())
{
    if ((annotationManager.InitFromFile("source.pdf") == GdPictureStatus.OK) &&
        (annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK))
    {
        int annotCount = annotationManager.GetAnnotationCount();
        GdPicture14.Annotations.Annotation annot = null;
        GdPicture14.Annotations.AnnotationComment comment = null;
        for (int a = 0; a < annotCount; a++)
        {
            annot = annotationManager.GetAnnotationFromIdx(a);
            if (annot != null)
            {
                GdPicture14.Annotations.Annotation.GdPictureAnnotationType annotType = annotationManager.GetAnnotationType(a);
                int commentIdx = annotationManager.GetFirstAnnotationCommentIdx(a);
                if ((annotationManager.GetStat()== GdPictureStatus.OK) && (commentIdx>-1))
                {
                    comment = (GdPicture14.Annotations.AnnotationComment)annotationManager.GetAnnotationFromIdx(commentIdx);
                    if (comment != null)
                        MessageBox.Show("The type of the annotation with comment: " + annotType + "\nThe first comment:\n" + comment.Text, "AnnotationManager.GetFirstAnnotationCommentIdx");
                    else
                        MessageBox.Show("Something goes wrong.", "AnnotationManager.GetFirstAnnotationCommentIdx");
                }
                //else This annotation does not include any comment.
            }
            else
                MessageBox.Show("Something goes wrong.", "AnnotationManager.GetFirstAnnotationCommentIdx");
        }
        annotationManager.Close();
    }
    else
        MessageBox.Show("The AnnotationManager can't be properly initialized. Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.GetFirstAnnotationCommentIdx");
}
See Also