GetPageLabel Method (GdPicturePDF)
Returns the page label associated with a page specified by its page number within the currently loaded PDF document. If no page labeling range is defined using the
GdPicturePDF.AddPageLabelsRange method, the value of the current page number as string is returned by default.
public string GetPageLabel(
int
)
public function GetPageLabel(
: Integer
): String;
public function GetPageLabel(
: int
) : String;
public: string* GetPageLabel(
int
)
public:
String^ GetPageLabel(
int
)
'Declaration
Public Function GetPageLabel( _
ByVal As Integer _
) As String
Parameters
- PageNo
- The required page number. This parameter is without any restrictions in this moment.
Return Value
The page label, if any is defined, or the current page number as a string. The
GdPicturePDF.GetStat method can be subsequently used to determine if this method has been successful.
How to find out the current page label for each page in the PDF document.
Dim caption As String = "Example: GetPageLabel"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim message As String = ""
Dim rangesCount As Integer = gdpicturePDF.GetPageLabelsRangeCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
message = message + rangesCount.ToString() + " page labeling ranges are defined in this PDF document." + vbCrLf
Else
message = message + "The GetPageLabelsRangeCount() method has failed with the status: " + status.ToString() + vbCrLf
End If
Dim pageCount As Integer = gdpicturePDF.GetPageCount()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim pageLabel As String = ""
For i As Integer = 1 To pageCount
pageLabel = gdpicturePDF.GetPageLabel(i)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
message = message + "The page number " + i.ToString() + " contains this page label = """ + pageLabel + """." + vbCrLf
Else
message = message + "The GetPageLabel() method has failed for the " + i.ToString() + ". page with the status: " + status.ToString() + vbCrLf
End If
Next
MessageBox.Show(message, caption)
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: GetPageLabel";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
string message = "";
int rangesCount = gdpicturePDF.GetPageLabelsRangeCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
message = message + rangesCount.ToString() + " page labeling ranges are defined in this PDF document.\n";
else
message = message + "The GetPageLabelsRangeCount() method has failed with the status: " + status.ToString() + "\n";
int pageCount = gdpicturePDF.GetPageCount();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string pageLabel = "";
for (int i = 1; i <= pageCount; i++)
{
pageLabel = gdpicturePDF.GetPageLabel(i);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
message = message + "The page number " + i.ToString() + " contains this page label = \"" + pageLabel + "\".\n";
}
else
message = message + "The GetPageLabel() method has failed for the " + i.ToString() + ". page with the status: " + status.ToString() + "\n";
}
MessageBox.Show(message, 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();