GetFirstAnnotationCommentIdx Method (AnnotationManager)
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.
public int GetFirstAnnotationCommentIdx(
int
)
public function GetFirstAnnotationCommentIdx(
: Integer
): Integer;
public function GetFirstAnnotationCommentIdx(
: int
) : int;
public: int GetFirstAnnotationCommentIdx(
int
)
public:
int GetFirstAnnotationCommentIdx(
int
)
'Declaration
Public Function GetFirstAnnotationCommentIdx( _
ByVal As Integer _
) As Integer
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.
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");
}