SelectPage Method (GdPicturePDF)
In This Topic
Selects a specified page (means sets as the current page) in the currently loaded PDF document.
Syntax
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.
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();
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