Reference Guide
GdPicture14 Namespace / GdPicturePDF Class / GetCurrentPage Method
Example





In This Topic
    GetCurrentPage Method (GdPicturePDF)
    In This Topic
    Returns the page number of the currently selected page within the loaded PDF document.
    Syntax
    'Declaration
     
    
    Public Function GetCurrentPage() As Integer
    public int GetCurrentPage()
    public function GetCurrentPage(): Integer; 
    public function GetCurrentPage() : int;
    public: int GetCurrentPage(); 
    public:
    int GetCurrentPage(); 

    Return Value

    The page number of the currently selected page. It is a value from 1 to GetPageCount.

    Please always use the GetStat method to determine if this method has been successful.

    Remarks
    Please note that 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 page (currently selected) in the PDF document.
    Dim oGdPicturePDF As New GdPicturePDF()
    Dim status As GdPictureStatus = oGdPicturePDF.LoadFromFile("test.pdf", False)
    'You can replace the previous line of code with this one and try the example again.
    'Dim status As GdPictureStatus = oGdPicturePDF.NewPDF();
    If status = GdPictureStatus.OK Then
        Dim pageNr As Integer = oGdPicturePDF.GetCurrentPage()
        status = oGdPicturePDF.GetStat()
        If status = GdPictureStatus.OK Then
            MessageBox.Show("The currently selected page in this PDF document is the page nr." + pageNr.ToString(), "Example: GetCurrentPage")
        Else
            MessageBox.Show("The GetCurrentPage() method has failed with the status: " + status.ToString(), "Example: GetCurrentPage")
        End If
    Else
        MessageBox.Show("The file can't be loaded.", "Example: GetCurrentPage")
    End If
    oGdPicturePDF.Dispose()
    GdPicturePDF oGdPicturePDF = new GdPicturePDF();
    GdPictureStatus status = oGdPicturePDF.LoadFromFile("test.pdf", false);
    //You can replace the previous line of code with this one and try the example again.
    //GdPictureStatus status = oGdPicturePDF.NewPDF();
    if (status == GdPictureStatus.OK)
    {
        int pageNr = oGdPicturePDF.GetCurrentPage();
        status = oGdPicturePDF.GetStat();
        if (status == GdPictureStatus.OK)
        {
            MessageBox.Show("The currently selected page in this PDF document is the page nr." + pageNr.ToString(), "Example: GetCurrentPage");
        }
        else
        {
            MessageBox.Show("The GetCurrentPage() method has failed with the status: " + status.ToString(), "Example: GetCurrentPage");
        }
    }
    else
    {
        MessageBox.Show("The file can't be loaded.", "Example: GetCurrentPage");
    }
    oGdPicturePDF.Dispose();
    See Also