GdPicture.NET.14
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.

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 page (currently selected) in the PDF document.
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
'You can replace the previous line of code with this one and try the example again.
'Dim status As GdPictureStatus = gdpicturePDF.NewPDF();
If status = GdPictureStatus.OK Then
    Dim pageNr As Integer = gdpicturePDF.GetCurrentPage()
    status = gdpicturePDF.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
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
//You can replace the previous line of code with this one and try the example again.
//GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
    int pageNr = gdpicturePDF.GetCurrentPage();
    status = gdpicturePDF.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");
}
gdpicturePDF.Dispose();
See Also