DeletePageLabelsRange Method (GdPicturePDF)
Removes a page labeling range specified by its index, previously defined by the
GdPicturePDF.AddPageLabelsRange method, within the currently loaded PDF document.
It is not allowed (see PDF Reference, Section "Page Labels") to delete the page labeling range with the index 0, if more than one labeling range is defined in the PDF document.
Parameters
- LabelingRangeIdx
- The index of the required labeling range to remove. It must be a value from 0 to GdPicturePDF.GetPageLabelsRangeCount-1.
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.
How to remove actual page labeling ranges, one by one, if any are defined, in the PDF document.
As it is mentioned above, the range with the index 0 is only allowed to delete if it is the only one labeling range defined in the document. Because of this in the example below we start to remove ranges from the last one to the first one.
Dim caption As String = "Example: DeletePageLabelsRange"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
Dim rangesCount As Integer = gdpicturePDF.GetPageLabelsRangeCount()
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
If rangesCount > 0 Then
Dim message As String = ""
For i As Integer = rangesCount - 1 To 0 Step -1
status = gdpicturePDF.DeletePageLabelsRange(i)
If status = GdPictureStatus.OK Then
message = message + "The page labeling range with the index " + i.ToString() + " has been successfully deleted." + vbCrLf
Else
message = message + "The DeletePageLabelsRange() method has failed for the " + i.ToString() + ". labeling range with the status: " + status.ToString() + vbCrLf
End If
Next
If gdpicturePDF.SaveToFile("test_DeletePageLabelsRange.pdf") = GdPictureStatus.OK Then
message = message + "The file has been saved."
Else
message = message + "The file can't be saved."
End If
MessageBox.Show(message, caption)
Else
MessageBox.Show("This PDF document contains no page labeling ranges.", caption)
End If
Else
MessageBox.Show("The GetPageLabelsRangeCount() 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: DeletePageLabelsRange";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int rangesCount = gdpicturePDF.GetPageLabelsRangeCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
if (rangesCount > 0)
{
string message = "";
for (int i = rangesCount-1; i >= 0; i--)
{
status = gdpicturePDF.DeletePageLabelsRange(i);
if (status == GdPictureStatus.OK)
message = message + "The page labeling range with the index " + i.ToString() + " has been successfully deleted.\n";
else
message = message + "The DeletePageLabelsRange() method has failed for the " + i.ToString() + ". labeling range with the status: " + status.ToString() + "\n";
}
if (gdpicturePDF.SaveToFile("test_DeletePageLabelsRange.pdf") == GdPictureStatus.OK)
message = message + "The file has been saved.";
else
message = message + "The file can't be saved.";
MessageBox.Show(message, caption);
}
else
MessageBox.Show("This PDF document contains no page labeling ranges.", caption);
}
else
MessageBox.Show("The GetPageLabelsRangeCount() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();