GdPicture.NET.14.API
GdPicture14 Namespace / GdPicturePDF Class / 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).

The GdPicturePDF.GetStat method can be subsequently used to determine if this method has been successful.

Remarks
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 gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("links.pdf", False)
If status = GdPictureStatus.OK Then
    status = gdpicturePDF.SelectPage(1)
    If status = GdPictureStatus.OK Then
        Dim linksCount As Integer = gdpicturePDF.GetPageLinksCount()
        If gdpicturePDF.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 = gdpicturePDF.GetPageLinkAnnotationIdx(i)
                    If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso (gdpicturePDF.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 gdpicturePDF.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
gdpicturePDF.Dispose()
string caption = "Example: GetPageLinkAnnotationIdx";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("links.pdf", false);
if (status == GdPictureStatus.OK)
{
    status = gdpicturePDF.SelectPage(1);
    if (status == GdPictureStatus.OK)
    {
        int linksCount = gdpicturePDF.GetPageLinksCount();
        if (gdpicturePDF.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 = gdpicturePDF.GetPageLinkAnnotationIdx(i);
                    if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
                        (gdpicturePDF.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 (gdpicturePDF.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);
}
gdpicturePDF.Dispose();
See Also