Reference Guide
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
    Please note that 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 oGdPicturePDF As New GdPicturePDF()
    If oGdPicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
        Dim count As Integer = oGdPicturePDF.GetPageCount()
        Dim status As GdPictureStatus = oGdPicturePDF.GetStat()
        If status = GdPictureStatus.OK Then
            Dim current As Integer = 0
            status = oGdPicturePDF.SelectPage(0)
            If status = GdPictureStatus.OK Then
                current = oGdPicturePDF.GetCurrentPage()
                status = oGdPicturePDF.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 = oGdPicturePDF.SelectPage(count + 1)
                If status = GdPictureStatus.OK Then
                    current = oGdPicturePDF.GetCurrentPage()
                    status = oGdPicturePDF.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 = oGdPicturePDF.SelectPage(1)
                    If status = GdPictureStatus.OK Then
                        current = oGdPicturePDF.GetCurrentPage()
                        status = oGdPicturePDF.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
    oGdPicturePDF.Dispose()
    string caption = "Example: SelectPage";
    GdPicturePDF oGdPicturePDF = new GdPicturePDF();
    if (oGdPicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
    {
        int count = oGdPicturePDF.GetPageCount();
        GdPictureStatus status = oGdPicturePDF.GetStat();
        if (status == GdPictureStatus.OK)
        {
            int current = 0;
            status = oGdPicturePDF.SelectPage(0);
            if (status == GdPictureStatus.OK)
            {
                current = oGdPicturePDF.GetCurrentPage();
                status = oGdPicturePDF.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 = oGdPicturePDF.SelectPage(count + 1);
                if (status == GdPictureStatus.OK)
                {
                    current = oGdPicturePDF.GetCurrentPage();
                    status = oGdPicturePDF.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 = oGdPicturePDF.SelectPage(1);
                    if (status == GdPictureStatus.OK)
                    {
                        current = oGdPicturePDF.GetCurrentPage();
                        status = oGdPicturePDF.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);
    oGdPicturePDF.Dispose();
    See Also