Dim caption As String = "Example: RemoveBookmark"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("bookmarks.pdf", False)
If status = GdPictureStatus.OK Then
Dim count As Integer = 0
Dim rootID As Integer = gdpicturePDF.GetBookmarkRootID()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim bookmarkID As Integer = 0
Dim status1 As GdPictureStatus = GdPictureStatus.OK
Do
bookmarkID = gdpicturePDF.GetBookmarkNextID(rootID)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
status1 = gdpicturePDF.RemoveBookmark(bookmarkID)
If status1 <> GdPictureStatus.OK Then
MessageBox.Show("The RemoveBookmark() method has failed with the status: " + status1.ToString(), caption)
Else
count += 1
End If
End If
Loop While (status = GdPictureStatus.OK) AndAlso (status1 = GdPictureStatus.OK)
If status1 = GdPictureStatus.OK Then
If status = GdPictureStatus.PropertyNotFound Then
status = gdpicturePDF.SaveToFile("bookmarks_RemoveLevel.pdf", False)
If status = GdPictureStatus.OK Then
MessageBox.Show("The example has been followed successfully." + vbCrLf + "The number of deleted bookmark items is: " + count.ToString(), caption)
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The GetBookmarkNextID() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
If status = GdPictureStatus.PropertyNotFound Then
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption)
Else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption)
End If
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: RemoveBookmark";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("bookmarks.pdf", false);
if (status == GdPictureStatus.OK)
{
int count = 0;
int rootID = gdpicturePDF.GetBookmarkRootID();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
int bookmarkID = 0;
GdPictureStatus status1 = GdPictureStatus.OK;
do
{
bookmarkID = gdpicturePDF.GetBookmarkNextID(rootID);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
status1 = gdpicturePDF.RemoveBookmark(bookmarkID);
if (status1 != GdPictureStatus.OK)
MessageBox.Show("The RemoveBookmark() method has failed with the status: " + status1.ToString(), caption);
else
count++;
}
}
while ((status == GdPictureStatus.OK) && (status1 == GdPictureStatus.OK));
if (status1 == GdPictureStatus.OK)
{
if (status == GdPictureStatus.PropertyNotFound)
{
status = gdpicturePDF.SaveToFile("bookmarks_RemoveLevel.pdf", false);
if (status == GdPictureStatus.OK)
MessageBox.Show("The example has been followed successfully.\nThe number of deleted bookmark items is: " + count.ToString(), caption);
else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The GetBookmarkNextID() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
if (status == GdPictureStatus.PropertyNotFound)
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption);
else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption);
}
}
else
{
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption);
}
gdpicturePDF.Dispose();