Dim caption As String = "Example: GetBookmarkPrevID"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("bookmarks.pdf", False)
If status = GdPictureStatus.OK Then
Dim rootID As Integer = gdpicturePDF.GetBookmarkRootID()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim siblingID As Integer = gdpicturePDF.GetBookmarkNextID(rootID)
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
Dim titles1 As String = gdpicturePDF.GetBookmarkTitle(rootID) + vbCrLf
Dim prevID As Integer = 0
While (status = GdPictureStatus.OK) AndAlso (siblingID > 0)
titles1 = titles1 + gdpicturePDF.GetBookmarkTitle(siblingID) + vbCrLf
prevID = siblingID
siblingID = gdpicturePDF.GetBookmarkNextID(siblingID)
status = gdpicturePDF.GetStat()
End While
If (status <> GdPictureStatus.OK) AndAlso (status <> GdPictureStatus.PropertyNotFound) Then
MessageBox.Show("The GetBookmarkNextID() method has failed with the status: " + status.ToString(), caption)
End If
Dim titles2 As String = ""
siblingID = prevID
If status = GdPictureStatus.PropertyNotFound Then
'No other bookmark is available on the same level as the root bookmark.
status = GdPictureStatus.OK
End If
While (status = GdPictureStatus.OK) AndAlso (siblingID > 0)
titles2 = titles2 + gdpicturePDF.GetBookmarkTitle(siblingID) + vbCrLf
siblingID = gdpicturePDF.GetBookmarkPrevID(siblingID)
status = gdpicturePDF.GetStat()
End While
If (status <> GdPictureStatus.OK) AndAlso (status <> GdPictureStatus.PropertyNotFound) Then
MessageBox.Show("The GetBookmarkPrevID() method has failed with the status: " + status.ToString(), caption)
End If
If (status = GdPictureStatus.OK) OrElse (status = GdPictureStatus.PropertyNotFound) Then
MessageBox.Show("From top to bottom:" + vbCrLf + titles1 + vbCrLf + "From bottom to top:" + vbCrLf + titles2 + vbCrLf + "The example has been successfully followed.", caption)
Else
MessageBox.Show("The example has NOT been successfully followed. Status: " + status.ToString())
End If
Else
If status = GdPictureStatus.PropertyNotFound Then
MessageBox.Show("The root bookmark doesn't contain any sibling bookmarks.", caption)
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: GetBookmarkPrevID";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("bookmarks.pdf", false);
if (status == GdPictureStatus.OK)
{
int rootID = gdpicturePDF.GetBookmarkRootID();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
int siblingID = gdpicturePDF.GetBookmarkNextID(rootID);
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string titles1 = gdpicturePDF.GetBookmarkTitle(rootID) + "\n";
int prevID = 0;
while ((status == GdPictureStatus.OK) && (siblingID > 0))
{
titles1 = titles1 + gdpicturePDF.GetBookmarkTitle(siblingID) + "\n";
prevID = siblingID;
siblingID = gdpicturePDF.GetBookmarkNextID(siblingID);
status = gdpicturePDF.GetStat();
}
if ((status != GdPictureStatus.OK) && (status != GdPictureStatus.PropertyNotFound))
MessageBox.Show("The GetBookmarkNextID() method has failed with the status: " + status.ToString(), caption);
string titles2 = "";
siblingID = prevID;
//No other bookmark is available on the same level as the root bookmark.
if (status == GdPictureStatus.PropertyNotFound)
status = GdPictureStatus.OK;
while ((status == GdPictureStatus.OK) && (siblingID > 0))
{
titles2 = titles2 + gdpicturePDF.GetBookmarkTitle(siblingID) + "\n";
siblingID = gdpicturePDF.GetBookmarkPrevID(siblingID);
status = gdpicturePDF.GetStat();
}
if ((status != GdPictureStatus.OK) && (status != GdPictureStatus.PropertyNotFound))
MessageBox.Show("The GetBookmarkPrevID() method has failed with the status: " + status.ToString(), caption);
if ((status == GdPictureStatus.OK) || (status == GdPictureStatus.PropertyNotFound))
MessageBox.Show("From top to bottom:\n" + titles1 + "\n" + "From bottom to top:\n" + titles2 + "\nThe example has been successfully followed.", caption);
else
MessageBox.Show("The example has NOT been successfully followed. Status: " + status.ToString());
}
else
{
if (status == GdPictureStatus.PropertyNotFound)
MessageBox.Show("The root bookmark doesn't contain any sibling bookmarks.", 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();