A unique bookmark identifier specifying a required bookmark object.

You can obtain this identifier using these methods: GdPicturePDF.NewBookmark, GdPicturePDF.GetBookmarkRootID, GdPicturePDF.GetBookmarkFirstChildID, GdPicturePDF.GetBookmarkNextID, GdPicturePDF.GetBookmarkPrevID or GdPicturePDF.GetBookmarkParentID.

Example





In This Topic
GdPicture14 Namespace / GdPicturePDF Class / GetBookmarkTitle Method

GetBookmarkTitle Method (GdPicturePDF)

In This Topic
Returns the title of a bookmark item specified by its unique identifier.
Syntax
'Declaration
 
Public Function GetBookmarkTitle( _
   ByVal BookmarkID As Integer _
) As String
public string GetBookmarkTitle( 
   int BookmarkID
)
public function GetBookmarkTitle( 
    BookmarkID: Integer
): String; 
public function GetBookmarkTitle( 
   BookmarkID : int
) : String;
public: string* GetBookmarkTitle( 
   int BookmarkID
) 
public:
String^ GetBookmarkTitle( 
   int BookmarkID
) 

Parameters

BookmarkID
A unique bookmark identifier specifying a required bookmark object.

You can obtain this identifier using these methods: GdPicturePDF.NewBookmark, GdPicturePDF.GetBookmarkRootID, GdPicturePDF.GetBookmarkFirstChildID, GdPicturePDF.GetBookmarkNextID, GdPicturePDF.GetBookmarkPrevID or GdPicturePDF.GetBookmarkParentID.

Return Value

The title of a specified bookmark item. The GdPicturePDF.GetStat method can be subsequently used to determine if this method has been successful.
Remarks
This method is only allowed for use with non-encrypted documents.

It is recommend to use the GdPicturePDF.GetStat method to identify the specific reason for the method's failure, if any.

Example
How to find out the title of the specified bookmark item. The title is subsequently displayed in the dialog box.
This example shows you how to find out the title of the root bookmark.
Dim caption As String = "Example: GetBookmarkTitle"
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 title As String = gdpicturePDF.GetBookmarkTitle(rootID)
        status = gdpicturePDF.GetStat()
        If status = GdPictureStatus.OK Then
            MessageBox.Show("The title of the root bookmark is: " + title, caption)
        Else
            MessageBox.Show("The GetBookmarkTitle() method has failed with the status: " + status.ToString(), caption)
        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: GetBookmarkTitle";
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)
    {
        string title = gdpicturePDF.GetBookmarkTitle(rootID);
        status = gdpicturePDF.GetStat();
        if (status == GdPictureStatus.OK)
            MessageBox.Show("The title of the root bookmark is: " + title, caption);
        else
            MessageBox.Show("The GetBookmarkTitle() 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();
This example shows you titles of all bookmark entries in the PDF document organized by the top level (denoted as level 0).
'The main entry point.
Dim caption As String = "Example: GetBookmarkTitle"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("bookmarks.pdf", False)
If status = GdPictureStatus.OK Then
    Dim message As String = ""
    Dim rootID As Integer = gdpicturePDF.GetBookmarkRootID()
    status = gdpicturePDF.GetStat()
    If status = GdPictureStatus.OK Then
        'Please see the sub-method below.
        ParseOutlines(gdpicturePDF, rootID, 0, message)
        MessageBox.Show("The example has been followed successfully.", 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()
            
'The sub-method.
Private Sub ParseOutlines(gdpicturePDF As GdPicturePDF, bookmarkID As Integer, level As Integer, ByRef message As String)
    Dim title As String = ""
    Dim status As GdPictureStatus = GdPictureStatus.OK
    While True
        title = gdpicturePDF.GetBookmarkTitle(bookmarkID)
        status = gdpicturePDF.GetStat()
        If status = GdPictureStatus.OK Then
            message = message + "Title: """ + title + """  Level: " + level.ToString() + vbCrLf
        Else
            message = message + "Title: this error occurs - " + status.ToString() + "    Level: " + level.ToString() + vbCrLf
        End If
            
        'Checking children.
        Dim childCount As Integer = gdpicturePDF.GetBookmarkChildCount(bookmarkID)
        status = gdpicturePDF.GetStat()
        If status <> GdPictureStatus.OK Then
            message = message + "This error occurs in GetBookmarkChildCount(): status = " + status.ToString() + vbCrLf
        End If
        If childCount > 0 Then
            Dim childID As Integer = gdpicturePDF.GetBookmarkFirstChildID(bookmarkID)
            status = gdpicturePDF.GetStat()
            If status <> GdPictureStatus.OK Then
                message = message + "This error occurs in GetBookmarkFirstChildID(): status = " + status.ToString() + vbCrLf
            Else
                ParseOutlines(gdpicturePDF, childID, level + 1, message)
            End If
        End If
        'Checking for subsequent bookmarks if the current bookmark has no children.
        bookmarkID = gdpicturePDF.GetBookmarkNextID(bookmarkID)
        status = gdpicturePDF.GetStat()
        If (status <> GdPictureStatus.OK) AndAlso (status <> GdPictureStatus.PropertyNotFound) Then
            message = message + "This error occurs in GetBookmarkNextID(): status = " + status.ToString() + vbCrLf
        End If
            
        If level = 0 Then
            MessageBox.Show(message, "Example: GetBookmarkTitle")
            message = ""
        End If
            
        If bookmarkID = 0 Then
            Exit While
        End If
    End While
    Return
End Sub
//The main entry point.
string caption = "Example: GetBookmarkTitle";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("bookmarks.pdf", false);
if (status == GdPictureStatus.OK)
{
    string message = "";
    int rootID = gdpicturePDF.GetBookmarkRootID();
    status = gdpicturePDF.GetStat();
    if (status == GdPictureStatus.OK)
    {
        //Please see the sub-method below.
        ParseOutlines(gdpicturePDF, rootID, 0, ref message);
        MessageBox.Show("The example has been followed successfully.", 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();
            
 //The sub-method.
 void ParseOutlines(GdPicturePDF gdpicturePDF, int bookmarkID, int level, ref string message)
 {
     string title = "";
     GdPictureStatus status = GdPictureStatus.OK;
     while (true)
     {
         title = gdpicturePDF.GetBookmarkTitle(bookmarkID);
         status = gdpicturePDF.GetStat();
         if (status == GdPictureStatus.OK)
             message = message + "Title: \"" + title + "\"  Level: " + level.ToString() + "\n";
         else
             message = message + "Title: this error occurs - " + status.ToString() + "    Level: " + level.ToString() + "\n";
            
         //Checking children.
         int childCount = gdpicturePDF.GetBookmarkChildCount(bookmarkID);
         status = gdpicturePDF.GetStat();
         if (status != GdPictureStatus.OK)
             message = message + "This error occurs in GetBookmarkChildCount(): status = " + status.ToString() + "\n";
         if (childCount > 0)
         {
             int childID = gdpicturePDF.GetBookmarkFirstChildID(bookmarkID);
             status = gdpicturePDF.GetStat();
             if (status != GdPictureStatus.OK)
                 message = message + "This error occurs in GetBookmarkFirstChildID(): status = " + status.ToString() + "\n";
             else
             {
                 ParseOutlines(gdpicturePDF, childID, level + 1, ref message);
             }
         }
         //Checking for subsequent bookmarks if the current bookmark has no children.
         bookmarkID = gdpicturePDF.GetBookmarkNextID(bookmarkID);
         status = gdpicturePDF.GetStat();
         if ((status != GdPictureStatus.OK) && (status != GdPictureStatus.PropertyNotFound))
             message = message + "This error occurs in GetBookmarkNextID(): status = " + status.ToString() + "\n";
            
         if (level == 0)
         {
             MessageBox.Show(message, "Example: GetBookmarkTitle");
             message = "";
         }
            
         if (bookmarkID == 0)
             break;
     }
     return;
}
See Also