Example





In This Topic
GdPicture14 Namespace / GdPicturePDF Class / GetPageLabelsRangeCount Method

GetPageLabelsRangeCount Method (GdPicturePDF)

In This Topic
Returns the number of all page labeling ranges, previously defined by the AddPageLabelsRange method, in the currently loaded PDF document.
Syntax
'Declaration
 
Public Function GetPageLabelsRangeCount() As Integer
public int GetPageLabelsRangeCount()
public function GetPageLabelsRangeCount(): Integer; 
public function GetPageLabelsRangeCount() : int;
public: int GetPageLabelsRangeCount(); 
public:
int GetPageLabelsRangeCount(); 

Return Value

The number of the currently defined labeling ranges in the document. 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 actual number of the defined page labeling ranges in the PDF document.
Dim caption As String = "Example: GetPageLabelsRangeCount"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
    Dim rangesCount As Integer = gdpicturePDF.GetPageLabelsRangeCount()
    Dim status As GdPictureStatus = gdpicturePDF.GetStat()
    If status = GdPictureStatus.OK Then
        If rangesCount > 0 Then
            Dim message As String = "This PDF document contains " + rangesCount.ToString() + " labeling ranges." + vbCrLf
            For i As Integer = 0 To rangesCount - 1
                Dim startPage As Integer = 0, num As Integer = 0
                Dim style As PdfPageLabelStyle = PdfPageLabelStyle.PdfPageLabelStyleUndefined
                Dim prefix As String = ""
                status = gdpicturePDF.GetPageLabelsRange(i, startPage, style, prefix, num)
                If status = GdPictureStatus.OK Then
                    message = message + "The labeling range with the index " + i.ToString() + " starts at the page number " + startPage.ToString() + " and has these attributes:" + vbCrLf + "style = " + style.ToString() + "    prefix = """ + prefix.ToString() + """    num.portion = " + num.ToString() + vbCrLf
                Else
                    message = message + "The GetPageLabelsRange() method has failed for the " + i.ToString() + ". labeling range with the status: " + status.ToString() + vbCrLf
                End If
            Next
            MessageBox.Show(message, caption)
        Else
            MessageBox.Show("This PDF document doesn't contain any page labeling ranges.", caption)
        End If
    Else
        MessageBox.Show("The GetPageLabelsRangeCount() 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: GetPageLabelsRangeCount";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
    int rangesCount = gdpicturePDF.GetPageLabelsRangeCount();
    GdPictureStatus status = gdpicturePDF.GetStat();
    if (status == GdPictureStatus.OK)
    {
        if (rangesCount > 0)
        {
            string message = "This PDF document contains " + rangesCount.ToString() + " labeling ranges.\n";
            for (int i = 0; i < rangesCount; i++)
            {
                int startPage = 0, num = 0;
                PdfPageLabelStyle style = PdfPageLabelStyle.PdfPageLabelStyleUndefined;
                string prefix = "";
                status = gdpicturePDF.GetPageLabelsRange(i, ref startPage, ref style, ref prefix, ref num);
                if (status == GdPictureStatus.OK)
                {
                    message = message + "The labeling range with the index " + i.ToString() + " starts at the page number " + startPage.ToString() + " and has these attributes:\n" +
                                        "style = " + style.ToString() + "    prefix = \"" + prefix.ToString() + "\"    num.portion = " + num.ToString() + "\n";
                }
                else
                    message = message + "The GetPageLabelsRange() method has failed for the " + i.ToString() + ". labeling range with the status: " + status.ToString() + "\n";
            }
            MessageBox.Show(message, caption);
        }
        else
            MessageBox.Show("This PDF document doesn't contain any page labeling ranges.", caption);
    }
    else
        MessageBox.Show("The GetPageLabelsRangeCount() method has failed with the status: " + status.ToString(), caption);
}
else
    MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
See Also