GdPicture.NET.14 (COM - ActiveX)~GdPicture14_namespace / GdPicture.NET.14 (COM - ActiveX)~GdPicture14.GdPicturePDF / GetPageLinkAnnotationIdx Method
The 0-based link index within the currently selected page. It must be a value from 0 to GdPicturePDF.GetPageLinksCount-1.
Example





In This Topic
    GetPageLinkAnnotationIdx Method (GdPicturePDF)
    In This Topic
    Translates a link index (only related to the currently selected page in the loaded PDF document) to an annotation index in order to allow working with this link object through the given set of methods related to the annotation objects. In a PDF document, a link is a subtype of the annotation type representing either a hypertext link to a destination elsewhere in the document or an action to be carried out.
    Syntax
    'Declaration
     
    
    Public Function GetPageLinkAnnotationIdx( _
       ByVal LinkIdx As Integer _
    ) As Integer
    public int GetPageLinkAnnotationIdx( 
       int LinkIdx
    )
    public function GetPageLinkAnnotationIdx( 
        LinkIdx: Integer
    ): Integer; 
    public function GetPageLinkAnnotationIdx( 
       LinkIdx : int
    ) : int;
    public: int GetPageLinkAnnotationIdx( 
       int LinkIdx
    ) 
    public:
    int GetPageLinkAnnotationIdx( 
       int LinkIdx
    ) 

    Parameters

    LinkIdx
    The 0-based link index within the currently selected page. It must be a value from 0 to GdPicturePDF.GetPageLinksCount-1.

    Return Value

    The annotation index of the specified link. You can subsequently use this index with the given set of methods related to the annotation objects (see the Annotations (PDF scheme) group of methods in the Reference Guide).

    Please always use the GdPicturePDF.GetStat method to determine if this method has been successful.

    Remarks
    Please note that this method is only allowed for use with non-encrypted documents.

    It is recommend to use the GdPicturePDF.GetStat method to identify the specific reason for the method's failure, if any.

    Example
    How to obtain an annotation index for links embedded within the first page of the PDF document. The example shows you how to subsequently use this index with the set of methods related to annotations.
    Dim caption As String = "Example: GetPageLinkAnnotationIdx"
    Dim oGdPicturePDF As New GdPicturePDF()
    Dim status As GdPictureStatus = oGdPicturePDF.LoadFromFile("links.pdf", False)
    If status = GdPictureStatus.OK Then
        status = oGdPicturePDF.SelectPage(1)
        If status = GdPictureStatus.OK Then
            Dim linksCount As Integer = oGdPicturePDF.GetPageLinksCount()
            If oGdPicturePDF.GetStat() = GdPictureStatus.OK Then
                If linksCount > 0 Then
                    Dim message As String = ""
                    For i As Integer = 0 To linksCount - 1
                        message = message + "Link Nr." + (i + 1).ToString()
                        Dim annotIdx As Integer = oGdPicturePDF.GetPageLinkAnnotationIdx(i)
                        If (oGdPicturePDF.GetStat() = GdPictureStatus.OK) AndAlso (oGdPicturePDF.SetAnnotationColor(annotIdx, 255, 0, 0) = GdPictureStatus.OK) Then
                            message = message + " has changed its color successfully." + vbCrLf
                        Else
                            message = message + " has failed to change its color." + vbCrLf
                        End If
                    Next
                    If oGdPicturePDF.SaveToFile("linksColoured.pdf") = GdPictureStatus.OK Then
                        MessageBox.Show(message + "The file has been saved successfully.", caption)
                    Else
                        MessageBox.Show(message + "The file can't be saved.", caption)
                    End If
                Else
                    MessageBox.Show("This page has no links.", caption)
                End If
            Else
                MessageBox.Show("The GetPageLinksCount() method has failed with the status: " + status.ToString(), caption)
            End If
        Else
            MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption)
        End If
    Else
        MessageBox.Show("The file can't be loaded.", caption)
    End If
    oGdPicturePDF.Dispose()
    string caption = "Example: GetPageLinkAnnotationIdx";
    GdPicturePDF oGdPicturePDF = new GdPicturePDF();
    GdPictureStatus status = oGdPicturePDF.LoadFromFile("links.pdf", false);
    if (status == GdPictureStatus.OK)
    {
        status = oGdPicturePDF.SelectPage(1);
        if (status == GdPictureStatus.OK)
        {
            int linksCount = oGdPicturePDF.GetPageLinksCount();
            if (oGdPicturePDF.GetStat() == GdPictureStatus.OK)
            {
                if (linksCount > 0)
                {
                    string message = "";
                    for (int i = 0; i <= linksCount - 1; i++)
                    {
                        message = message + "Link Nr." + (i + 1).ToString();
                        int annotIdx = oGdPicturePDF.GetPageLinkAnnotationIdx(i);
                        if ((oGdPicturePDF.GetStat() == GdPictureStatus.OK) &&
                            (oGdPicturePDF.SetAnnotationColor(annotIdx, 255, 0, 0) == GdPictureStatus.OK))
                        {
                            message = message + " has changed its color successfully.\n";
                        }
                        else
                        {
                            message = message + " has failed to change its color.\n";
                        }
                    }
                    if (oGdPicturePDF.SaveToFile("linksColoured.pdf") == GdPictureStatus.OK)
                    {
                        MessageBox.Show(message + "The file has been saved successfully.", caption);
                    }
                    else
                    {
                        MessageBox.Show(message + "The file can't be saved.", caption);
                    }
                }
                else
                {
                    MessageBox.Show("This page has no links.", caption);
                }
            }
            else
            {
                MessageBox.Show("The GetPageLinksCount() method has failed with the status: " + status.ToString(), caption);
            }
        }
        else
        {
            MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption);
        }
    }
    else
    {
        MessageBox.Show("The file can't be loaded.", caption);
    }
    oGdPicturePDF.Dispose();
    See Also

    Reference

    GdPicture.NET.14 (COM - ActiveX)~GdPicture14.GdPicturePDF
    GdPicturePDF Members
    GetPageLinksCount Method
    AddLinkAnnotation(Single,Single,Single,Single,Boolean,Byte,Byte,Byte) Method