GdPicture.NET.14.API
GdPicture14 Namespace / AnnotationManager Class / GetAnnotationIdx Method
The required GdPictureXMP annotation object.
Example





In This Topic
GetAnnotationIdx Method (AnnotationManager)
In This Topic
Returns an index of the specified GdPicture/XMP annotation object within 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 GetAnnotationIdx( _
   ByVal Annot As Annotation _
) As Integer
public int GetAnnotationIdx( 
   Annotation Annot
)
public function GetAnnotationIdx( 
    Annot: Annotation
): Integer; 
public function GetAnnotationIdx( 
   Annot : Annotation
) : int;
public: int GetAnnotationIdx( 
   Annotation* Annot
) 
public:
int GetAnnotationIdx( 
   Annotation^ Annot
) 

Parameters

Annot
The required GdPictureXMP annotation object.

Return Value

An index of the specified GdPicture/XMP annotation object. 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 specified annotation has been found or -1 if the specified annotation has not been found within the selected page.

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 get an index of the newly added annotation.
Dim status As GdPictureStatus = GdPictureStatus.OK
Dim annotationManager As AnnotationManager = New AnnotationManager()
If (annotationManager.InitFromFile("source.pdf") = GdPictureStatus.OK) AndAlso
   (annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) Then
    Dim annotXML As String = ""
    Dim stamp As GdPicture14.Annotations.AnnotationRubberStamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5F, 0.5F, 2, 1, "APPROVED")
    If stamp IsNot Nothing Then
        stamp.Rotation = 20
        If annotationManager.SaveAnnotationsToPage() = GdPictureStatus.OK Then
            Dim annotIdx As Integer = annotationManager.GetAnnotationIdx(stamp)
            If annotationManager.GetStat() = GdPictureStatus.OK Then
                annotXML = annotationManager.GetAnnotationXML(annotIdx)
                If annotationManager.GetStat() = GdPictureStatus.OK Then
                    status = annotationManager.SaveDocumentToPDF("source_stamped.pdf")
                End If
            Else
                status = annotationManager.GetStat()
            End If
        Else
            status = annotationManager.GetStat()
        End If
        stamp.Dispose()
    End If
    annotationManager.Close()
    If status = GdPictureStatus.OK Then
        If (annotationManager.InitFromFile("dest.pdf") = GdPictureStatus.OK) AndAlso
           (annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) Then
            Dim annot As GdPicture14.Annotations.Annotation = annotationManager.AddAnnotationFromXML(annotXML)
            If annot IsNot Nothing Then status = annotationManager.SaveAnnotationsToPage()
            If status = GdPictureStatus.OK Then
                status = annotationManager.SaveDocumentToPDF("dest_stamped.pdf")
            End If
        Else
            status = annotationManager.GetStat()
        End If
    End If
    annotationManager.Close()
Else
    status = annotationManager.GetStat()
End If
If status = GdPictureStatus.OK Then
    MessageBox.Show("Done!", "AnnotationManager.GetAnnotationIdx")
Else
    MessageBox.Show("Error!   Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.GetAnnotationIdx")
End If
annotationManager.Dispose()
GdPictureStatus status = GdPictureStatus.OK;
AnnotationManager annotationManager = new AnnotationManager();
if ((annotationManager.InitFromFile("source.pdf") == GdPictureStatus.OK) &&
    (annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK))
{
    string annotXML = "";
    GdPicture14.Annotations.AnnotationRubberStamp stamp = annotationManager.AddRubberStampAnnot(Color.Red, 0.5f, 0.5f, 2, 1, "APPROVED");
    if (stamp != null)
    {
        stamp.Rotation = 20;
        if (annotationManager.SaveAnnotationsToPage() == GdPictureStatus.OK)
        {
            int annotIdx = annotationManager.GetAnnotationIdx(stamp);
            if (annotationManager.GetStat() == GdPictureStatus.OK)
            {
                annotXML = annotationManager.GetAnnotationXML(annotIdx);
                if (annotationManager.GetStat() == GdPictureStatus.OK)
                    status = annotationManager.SaveDocumentToPDF("source_stamped.pdf");
            }
            else status = annotationManager.GetStat();
        }
        else status = annotationManager.GetStat();
        stamp.Dispose();
    }
    annotationManager.Close();
    if (status == GdPictureStatus.OK)
    {
        if ((annotationManager.InitFromFile("dest.pdf") == GdPictureStatus.OK) &&
            (annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK))
        {
            GdPicture14.Annotations.Annotation annot = annotationManager.AddAnnotationFromXML(annotXML);
            if (annot != null)
                status = annotationManager.SaveAnnotationsToPage();
            if (status == GdPictureStatus.OK)
                status = annotationManager.SaveDocumentToPDF("dest_stamped.pdf");
        }
        else status = annotationManager.GetStat();
    }
    annotationManager.Close();
}
else status = annotationManager.GetStat();
if (status == GdPictureStatus.OK)
    MessageBox.Show("Done!", "AnnotationManager.GetAnnotationIdx");
else
    MessageBox.Show("Error!   Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.GetAnnotationIdx");
annotationManager.Dispose();
See Also