GetBookmarkRootID Method (GdPicturePDF)
Returns a unique identifier of the root bookmark in the currently loaded PDF document.
Bookmarks (also called outline items in the PDF Reference) are items organized in a tree-structured hierarchy, which serves as a visual table of contents to display the document’s structure to the user. A root bookmark is the first top-level bookmark item in this hierarchy.
public int GetBookmarkRootID()
public function GetBookmarkRootID(): Integer;
public function GetBookmarkRootID() : int;
public: int GetBookmarkRootID();
public:
int GetBookmarkRootID();
'Declaration
Public Function GetBookmarkRootID() As Integer
Return Value
A unique bookmark identifier of the root bookmark. The
GdPicturePDF.GetStat method can be subsequently used to determine if this method has been successful.
How to obtain an identifier of the root bookmark. The title of this bookmark item is subsequently displayed in the dialog box.
This example shows you how you can use the GetBookmarkRootID() method to check if the PDF document contains bookmarks.
Dim caption As String = "Example: GetBookmarkRootID"
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
MessageBox.Show("The title of the root bookmark is: " + gdpicturePDF.GetBookmarkTitle(rootID), caption)
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: GetBookmarkRootID";
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)
MessageBox.Show("The title of the root bookmark is: " + gdpicturePDF.GetBookmarkTitle(rootID), 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();
This example shows you another approach how to obtain the identifier of the root bookmark.
Dim caption As String = "Example: GetBookmarkRootID"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("bookmarks.pdf", False)
If status = GdPictureStatus.OK Then
Dim bookmarksCount As Integer = gdpicturePDF.GetBookmarkCount()
status = gdpicturePDF.GetStat()
If status <> GdPictureStatus.OK Then
MessageBox.Show("The GetBookmarkCount() method has failed with the status: " + status.ToString(), caption)
Else
If bookmarksCount = 0 Then
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption)
Else
MessageBox.Show("The number of bookmarks in this PDF document is: " + bookmarksCount.ToString(), caption)
Dim rootID As Integer = gdpicturePDF.GetBookmarkRootID()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The title of the root bookmark is: " + gdpicturePDF.GetBookmarkTitle(rootID), caption)
Else
MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption)
End If
End If
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetBookmarkRootID";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("bookmarks.pdf", false);
if (status == GdPictureStatus.OK)
{
int bookmarksCount = gdpicturePDF.GetBookmarkCount();
status = gdpicturePDF.GetStat();
if (status != GdPictureStatus.OK)
MessageBox.Show("The GetBookmarkCount() method has failed with the status: " + status.ToString(), caption);
else
{
if (bookmarksCount == 0)
MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption);
else
{
MessageBox.Show("The number of bookmarks in this PDF document is: " + bookmarksCount.ToString(), caption);
int rootID = gdpicturePDF.GetBookmarkRootID();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
MessageBox.Show("The title of the root bookmark is: " + gdpicturePDF.GetBookmarkTitle(rootID), 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();