GdPicture.NET.14
GdPicture14 Namespace / GdPicturePDF Class / GetPageLabel Method
The required page number. This parameter is without any restrictions in this moment.
Example





In This Topic
GetPageLabel Method (GdPicturePDF)
In This Topic
Returns the page label associated with a page specified by its page number within the currently loaded PDF document. If no page labeling range is defined using the AddPageLabelsRange method, the value of the current page number as string is returned by default.
Syntax
'Declaration
 
Public Function GetPageLabel( _
   ByVal PageNo As Integer _
) As String
public string GetPageLabel( 
   int PageNo
)
public function GetPageLabel( 
    PageNo: Integer
): String; 
public function GetPageLabel( 
   PageNo : int
) : String;
public: string* GetPageLabel( 
   int PageNo
) 
public:
String^ GetPageLabel( 
   int PageNo
) 

Parameters

PageNo
The required page number. This parameter is without any restrictions in this moment.

Return Value

The page label, if any is defined, or the current page number as a string. The 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 GetStat method to identify the specific reason for the method's failure, if any.

Example
How to find out the current page label for each page in the PDF document.
Dim caption As String = "Example: GetPageLabel"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
    Dim message As String = ""
    Dim rangesCount As Integer = gdpicturePDF.GetPageLabelsRangeCount()
    Dim status As GdPictureStatus = gdpicturePDF.GetStat()
    If status = GdPictureStatus.OK Then
        message = message + rangesCount.ToString() + " page labeling ranges are defined in this PDF document." + vbCrLf
    Else
        message = message + "The GetPageLabelsRangeCount() method has failed with the status: " + status.ToString() + vbCrLf
    End If
    Dim pageCount As Integer = gdpicturePDF.GetPageCount()
    status = gdpicturePDF.GetStat()
    If status = GdPictureStatus.OK Then
        Dim pageLabel As String = ""
        For i As Integer = 1 To pageCount
            pageLabel = gdpicturePDF.GetPageLabel(i)
            status = gdpicturePDF.GetStat()
            If status = GdPictureStatus.OK Then
                message = message + "The page number " + i.ToString() + " contains this page label = """ + pageLabel + """." + vbCrLf
            Else
                message = message + "The GetPageLabel() method has failed for the " + i.ToString() + ". page with the status: " + status.ToString() + vbCrLf
            End If
        Next
        MessageBox.Show(message, caption)
    Else
        MessageBox.Show("The GetPageCount() 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: GetPageLabel";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
    string message = "";
    int rangesCount = gdpicturePDF.GetPageLabelsRangeCount();
    GdPictureStatus status = gdpicturePDF.GetStat();
    if (status == GdPictureStatus.OK)
        message = message + rangesCount.ToString() + " page labeling ranges are defined in this PDF document.\n";
    else
        message = message + "The GetPageLabelsRangeCount() method has failed with the status: " + status.ToString() + "\n";
    int pageCount = gdpicturePDF.GetPageCount();
    status = gdpicturePDF.GetStat();
    if (status == GdPictureStatus.OK)
    {
        string pageLabel = "";
        for (int i = 1; i <= pageCount; i++)
        {
            pageLabel = gdpicturePDF.GetPageLabel(i);
            status = gdpicturePDF.GetStat();
            if (status == GdPictureStatus.OK)
            {
                message = message + "The page number " + i.ToString() + " contains this page label = \"" + pageLabel + "\".\n";
            }
            else
                message = message + "The GetPageLabel() method has failed for the " + i.ToString() + ". page with the status: " + status.ToString() + "\n";
        }
        MessageBox.Show(message, caption);
    }
    else
        MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
else
    MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
See Also