VintaSoft Imaging .NET SDK 12.3: Documentation for .NET developer
Vintasoft.Imaging.Pdf.Tree Namespace / PdfBookmarkCollection Class
Members Object Syntax Example Hierarchy Requirements SeeAlso
In This Topic
    PdfBookmarkCollection Class
    In This Topic
    Represents a PdfBookmark collection.
    Object Model
    PdfBookmark PdfDocument PdfIndirectReference PdfBasicObject PdfBookmarkCollection
    Syntax
    'Declaration
    
    <DefaultMemberAttribute("Item")>
    Public NotInheritable Class PdfBookmarkCollection
       Inherits PdfTreeNodeBase
    
    
    [DefaultMember("Item")]
    public sealed class PdfBookmarkCollection : PdfTreeNodeBase
    
    
    [DefaultMember("Item")]
    public __gc __sealed class PdfBookmarkCollection : public PdfTreeNodeBase*
    
    
    [DefaultMember("Item")]
    public ref class PdfBookmarkCollection sealed : public PdfTreeNodeBase^
    
    
    Example

    Here is an example that shows how to find a PDF bookmark by bookmark name:

    
    ''' <summary>
    ''' Finds the bookmark.
    ''' </summary>
    ''' <param name="document">The document.</param>
    ''' <param name="bookmarkTitle">The title of bookmark.</param>
    Public Function FindBookmark(document As Vintasoft.Imaging.Pdf.PdfDocument, bookmarkTitle As String) As Vintasoft.Imaging.Pdf.Tree.PdfBookmark
        Return FindBookmark(document.Bookmarks, bookmarkTitle)
    End Function
    
    ''' <summary>
    ''' Finds the bookmark.
    ''' </summary>
    ''' <param name="bookmarks">The bookmarks.</param>
    ''' <param name="bookmarkTitle">The title of bookmark.</param>
    Private Function FindBookmark(bookmarks As Vintasoft.Imaging.Pdf.Tree.PdfBookmarkCollection, bookmarkTitle As String) As Vintasoft.Imaging.Pdf.Tree.PdfBookmark
        If bookmarks Is Nothing Then
            Return Nothing
        End If
    
        For i As Integer = 0 To bookmarks.Count - 1
            If bookmarks(i).Title = bookmarkTitle Then
                Return bookmarks(i)
            End If
    
            Dim result As Vintasoft.Imaging.Pdf.Tree.PdfBookmark = FindBookmark(bookmarks(i).ChildBookmarks, bookmarkTitle)
            If result IsNot Nothing Then
                Return result
            End If
        Next
    
        Return Nothing
    End Function
    
    
    
    /// <summary>
    /// Finds the bookmark.
    /// </summary>
    /// <param name="document">The document.</param>
    /// <param name="bookmarkTitle">The title of bookmark.</param>
    public Vintasoft.Imaging.Pdf.Tree.PdfBookmark FindBookmark(
        Vintasoft.Imaging.Pdf.PdfDocument document, string bookmarkTitle)
    {
        return FindBookmark(document.Bookmarks, bookmarkTitle);
    }
    
    /// <summary>
    /// Finds the bookmark.
    /// </summary>
    /// <param name="bookmarks">The bookmarks.</param>
    /// <param name="bookmarkTitle">The title of bookmark.</param>
    private Vintasoft.Imaging.Pdf.Tree.PdfBookmark FindBookmark(
        Vintasoft.Imaging.Pdf.Tree.PdfBookmarkCollection bookmarks, string bookmarkTitle)
    {
        if (bookmarks == null)
            return null;
    
        for (int i = 0; i < bookmarks.Count; i++)
        {
            if (bookmarks[i].Title == bookmarkTitle)
                return bookmarks[i];
    
            Vintasoft.Imaging.Pdf.Tree.PdfBookmark result = 
                FindBookmark(bookmarks[i].ChildBookmarks, bookmarkTitle);
            if (result != null)
                return result;
        }
    
        return null;
    }
    
    

    Inheritance Hierarchy

    System.Object
       Vintasoft.Imaging.Pdf.Tree.PdfTreeNodeBase
          Vintasoft.Imaging.Pdf.Tree.PdfBookmarkCollection

    Requirements

    Target Platforms: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    See Also