GdPicture.NET.14
GdPicture14 Namespace / GdPicturePDF Class / SelectPage Method
The required page number. This parameter is without any restrictions.

If the specified value is out of the expected range from 1 to GetPageCount, the next-lower or the next-greater value in this range is automatically used. It means that for values lower than 1 the first page is selected and for values greater than GetPageCount the last page is selected, as it is shown in the example below.

Example





In This Topic
SelectPage Method (GdPicturePDF)
In This Topic
Selects a specified page (means sets as the current page) in the currently loaded PDF document.
Syntax
'Declaration
 
Public Function SelectPage( _
   ByVal PageNo As Integer _
) As GdPictureStatus
public GdPictureStatus SelectPage( 
   int PageNo
)
public function SelectPage( 
    PageNo: Integer
): GdPictureStatus; 
public function SelectPage( 
   PageNo : int
) : GdPictureStatus;
public: GdPictureStatus SelectPage( 
   int PageNo
) 
public:
GdPictureStatus SelectPage( 
   int PageNo
) 

Parameters

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

If the specified value is out of the expected range from 1 to GetPageCount, the next-lower or the next-greater value in this range is automatically used. It means that for values lower than 1 the first page is selected and for values greater than GetPageCount the last page is selected, as it is shown in the example below.

Return Value

A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.

We strongly recommend always checking this status first.

Remarks
This method is only allowed for use with non-encrypted documents.
Example
How to select a specified page in the PDF document.
Dim caption As String = "Example: SelectPage"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
    Dim count As Integer = gdpicturePDF.GetPageCount()
    Dim status As GdPictureStatus = gdpicturePDF.GetStat()
    If status = GdPictureStatus.OK Then
        Dim current As Integer = 0
        status = gdpicturePDF.SelectPage(0)
        If status = GdPictureStatus.OK Then
            current = gdpicturePDF.GetCurrentPage()
            status = gdpicturePDF.GetStat()
            If status = GdPictureStatus.OK Then
                MessageBox.Show("The currently selected page is page nr." + current.ToString(), caption)
            Else
                MessageBox.Show("The GetCurrentPage() method has failed with the status: " + status.ToString(), caption)
            End If
            
            status = gdpicturePDF.SelectPage(count + 1)
            If status = GdPictureStatus.OK Then
                current = gdpicturePDF.GetCurrentPage()
                status = gdpicturePDF.GetStat()
                If status = GdPictureStatus.OK Then
                    MessageBox.Show("The currently selected page is page nr." + current.ToString(), caption)
                Else
                    MessageBox.Show("The GetCurrentPage() method has failed with the status: " + status.ToString(), caption)
                End If
            
                status = gdpicturePDF.SelectPage(1)
                If status = GdPictureStatus.OK Then
                    current = gdpicturePDF.GetCurrentPage()
                    status = gdpicturePDF.GetStat()
                    If status = GdPictureStatus.OK Then
                        MessageBox.Show("The currently selected page is page nr." + current.ToString(), caption)
                    Else
                        MessageBox.Show("The GetCurrentPage() method has failed with the status: " + status.ToString(), caption)
                    End If
                Else
                    MessageBox.Show("The SelectPage(1) method has failed with the status: " + status.ToString(), caption)
                End If
            Else
                MessageBox.Show("The SelectPage(count + 1) method has failed with the status: " + status.ToString(), caption)
            End If
        Else
            MessageBox.Show("The SelectPage(0) method has failed with the status: " + status.ToString(), caption)
        End If
    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: SelectPage";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
    int count = gdpicturePDF.GetPageCount();
    GdPictureStatus status = gdpicturePDF.GetStat();
    if (status == GdPictureStatus.OK)
    {
        int current = 0;
        status = gdpicturePDF.SelectPage(0);
        if (status == GdPictureStatus.OK)
        {
            current = gdpicturePDF.GetCurrentPage();
            status = gdpicturePDF.GetStat();
            if (status == GdPictureStatus.OK)
                MessageBox.Show("The currently selected page is page nr." + current.ToString(), caption);
            else
                MessageBox.Show("The GetCurrentPage() method has failed with the status: " + status.ToString(), caption);
            
            status = gdpicturePDF.SelectPage(count + 1);
            if (status == GdPictureStatus.OK)
            {
                current = gdpicturePDF.GetCurrentPage();
                status = gdpicturePDF.GetStat();
                if (status == GdPictureStatus.OK)
                    MessageBox.Show("The currently selected page is page nr." + current.ToString(), caption);
                else
                    MessageBox.Show("The GetCurrentPage() method has failed with the status: " + status.ToString(), caption);
            
                status = gdpicturePDF.SelectPage(1);
                if (status == GdPictureStatus.OK)
                {
                    current = gdpicturePDF.GetCurrentPage();
                    status = gdpicturePDF.GetStat();
                    if (status == GdPictureStatus.OK)
                        MessageBox.Show("The currently selected page is page nr." + current.ToString(), caption);
                    else
                        MessageBox.Show("The GetCurrentPage() method has failed with the status: " + status.ToString(), caption);
                }
                else
                    MessageBox.Show("The SelectPage(1) method has failed with the status: " + status.ToString(), caption);
            }
            else
                MessageBox.Show("The SelectPage(count + 1) method has failed with the status: " + status.ToString(), caption);
        }
        else
            MessageBox.Show("The SelectPage(0) method has failed with the status: " + status.ToString(), 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