Search Results for

    Show / Hide Table of Contents

    Class PdfBookMarkCollection

    Manages a collection of PDF bookmarks (document outline) for navigation. Supports adding, removing, and traversing bookmarks in a hierarchical structure.

    Access the root collection via Bookmarks. Each bookmark can have its own Children collection for nested entries.

    Example - Build complete document outline:

    var pdf = PdfDocument.FromFile("manual.pdf");
    

    // Create root-level chapters: var intro = pdf.Bookmarks.AddBookMarkAtEnd("Introduction", 0); var basics = pdf.Bookmarks.AddBookMarkAtEnd("Basic Concepts", 5); var advanced = pdf.Bookmarks.AddBookMarkAtEnd("Advanced Topics", 20);

    // Add nested sections: intro.Children.AddBookMarkAtEnd("Welcome", 0); intro.Children.AddBookMarkAtEnd("Getting Started", 2);

    basics.Children.AddBookMarkAtEnd("Core Features", 5); basics.Children.AddBookMarkAtEnd("Configuration", 10);

    // List all bookmarks: foreach (var bm in pdf.Bookmarks.GetAllBookmarks()) Console.WriteLine($"{bm.Text} → Page {bm.PageIndex + 1}");

    pdf.SaveAs("manual_with_outline.pdf");

    Inheritance
    System.Object
    PdfClientAccessor
    PdfBookMarkCollection
    Implements
    System.Collections.Generic.IEnumerable<IronPdf.Bookmarks.IPdfBookmark>
    System.Collections.IEnumerable
    IPdfBookMarkCollection
    Namespace: IronPdf.Bookmarks
    Assembly: IronPdf.dll
    Syntax
    public class PdfBookMarkCollection : PdfClientAccessor, IPdfBookMarkCollection

    PDF bookmarks in IronPDF is handled through PdfBookMarkCollection. It manages a collection of PDF bookmarks (document outline) for navigation.

    PdfBookMarkCollection matters when an application needs to configure or invoke PDF bookmarks from C# code. The class encapsulates the related options and behavior in a single object that is set up once and reused across render or processing calls. Typical scenarios include batch generation pipelines, templated document workflows, and integration with existing C# document services.

    To use PdfBookMarkCollection, instantiate or obtain it from the relevant entry point in the IronPDF C# API. Key properties include Count, FirstBookmark, LastBookmark, Parent. Assign options or invoke methods on the instance to configure or perform the operation. The access PDF DOM object covers typical usage in C# end to end.

    using IronPdf;
    
    // Obtain PdfBookMarkCollection from the relevant entry point in the IronPDF API
    void Configure(PdfBookMarkCollection instance)
    {
        var current = instance.Count;
        instance.AddBookMarkAtEnd();
    }

    For the broader workflow, see the bookmarks guide in the IronPDF C# documentation. For broader context, the PDF bookmarks portion of the IronPDF C# API contains related types that work with PdfBookMarkCollection directly. PdfBookMarkCollection instances inherit additional members from PdfClientAccessor that may be relevant in advanced scenarios. In application code, treat PdfBookMarkCollection as a configured object that is constructed once and reused across operations rather than instantiated per call. Configuration is generally idempotent: assigning the same property value twice has the same effect as assigning it once. For diagnostic purposes, inspect the relevant PdfBookMarkCollection property after each operation to confirm the configured state. See the constructors, properties, and methods tables below for the complete API surface of PdfBookMarkCollection. Application code typically obtains or instantiates a single PdfBookMarkCollection and shares it across multiple IronPDF operations rather than recreating it per call.

    Properties

    Count

    Total number of bookmarks, including all nested bookmarks

    Declaration
    public int Count { get; }
    Property Value
    Type Description
    System.Int32

    FirstBookmark

    First bookmark within the bookmark collection at the current level

    Declaration
    public IPdfBookmark FirstBookmark { get; }
    Property Value
    Type Description
    IronPdf.Bookmarks.IPdfBookmark

    LastBookmark

    Last bookmark within the bookmark collection at the current level

    Declaration
    public IPdfBookmark LastBookmark { get; }
    Property Value
    Type Description
    IronPdf.Bookmarks.IPdfBookmark

    Parent

    Bookmark which contains this bookmark collection

    Declaration
    public IPdfBookmark Parent { get; }
    Property Value
    Type Description
    IronPdf.Bookmarks.IPdfBookmark

    Methods

    AddBookMarkAtEnd(String, Int32)

    Add a new bookmark at the end of this bookmark collection

    Declaration
    public IPdfBookmark AddBookMarkAtEnd(string text, int pageIndex)
    Parameters
    Type Name Description
    System.String text

    The display text for the link.

    System.Int32 pageIndex

    The zero based page number to link to. E.g. Page 1 has a PageIndex of 0

    Returns
    Type Description
    IronPdf.Bookmarks.IPdfBookmark

    Newly added bookmark

    AddBookMarkAtStart(String, Int32)

    Add a new bookmark at the start of this bookmark collection

    Declaration
    public IPdfBookmark AddBookMarkAtStart(string text, int pageIndex)
    Parameters
    Type Name Description
    System.String text

    The display text for the link.

    System.Int32 pageIndex

    The zero based page number to link to. E.g. Page 1 has a PageIndex of 0

    Returns
    Type Description
    IronPdf.Bookmarks.IPdfBookmark

    Newly added bookmark

    GetAllBookmarks()

    Retrieve all bookmarks within this collection, recursively retrieve all children of bookmarks within this collection, and return a flat list

    Declaration
    public List<IPdfBookmark> GetAllBookmarks()
    Returns
    Type Description
    System.Collections.Generic.List<IronPdf.Bookmarks.IPdfBookmark>

    A flattened list of all bookmarks in this collection and all of their children

    GetBookmarkAfter(IPdfBookmark)

    Retrieve the next bookmark after the specified bookmark at the current level

    Declaration
    public IPdfBookmark GetBookmarkAfter(IPdfBookmark previousBookmark)
    Parameters
    Type Name Description
    IronPdf.Bookmarks.IPdfBookmark previousBookmark

    Previous bookmark

    Returns
    Type Description
    IronPdf.Bookmarks.IPdfBookmark

    Next bookmark at the current level

    GetBookmarkBefore(IPdfBookmark)

    Retrieve the previous bookmark before the specified bookmark at the current level

    Declaration
    public IPdfBookmark GetBookmarkBefore(IPdfBookmark nextBookmark)
    Parameters
    Type Name Description
    IronPdf.Bookmarks.IPdfBookmark nextBookmark

    Next bookmark

    Returns
    Type Description
    IronPdf.Bookmarks.IPdfBookmark

    Previous bookmark at the current level

    GetEnumerator()

    Declaration
    public IEnumerator<IPdfBookmark> GetEnumerator()
    Returns
    Type Description
    System.Collections.Generic.IEnumerator<IronPdf.Bookmarks.IPdfBookmark>

    InsertBookMarkAfter(String, Int32, IPdfBookmark)

    Insert a new bookmark after the specified bookmark

    Declaration
    public IPdfBookmark InsertBookMarkAfter(string text, int pageIndex, IPdfBookmark previousBookmark)
    Parameters
    Type Name Description
    System.String text

    The display text for the link.

    System.Int32 pageIndex

    The zero based page number to link to. E.g. Page 1 has a PageIndex of 0

    IronPdf.Bookmarks.IPdfBookmark previousBookmark

    Bookmark after which to insert a new bookmark

    Returns
    Type Description
    IronPdf.Bookmarks.IPdfBookmark

    InsertBookMarkBefore(String, Int32, IPdfBookmark)

    Insert a new bookmark before the specified bookmark

    Declaration
    public IPdfBookmark InsertBookMarkBefore(string text, int pageIndex, IPdfBookmark nextBookmark)
    Parameters
    Type Name Description
    System.String text

    The display text for the link.

    System.Int32 pageIndex

    The zero based page number to link to. E.g. Page 1 has a PageIndex of 0

    IronPdf.Bookmarks.IPdfBookmark nextBookmark

    Bookmark before which to insert a new bookmark

    Returns
    Type Description
    IronPdf.Bookmarks.IPdfBookmark

    RemoveBookMark(IPdfBookmark)

    Removes the specified bookmark from this bookmark collection

    Declaration
    public void RemoveBookMark(IPdfBookmark bookmark)
    Parameters
    Type Name Description
    IronPdf.Bookmarks.IPdfBookmark bookmark

    The bookmark object to remove.

    RemoveBookMarkAt(Int32)

    Removes a bookmark at the specified index from this bookmark collection or any of its children

    Declaration
    public void RemoveBookMarkAt(int index)
    Parameters
    Type Name Description
    System.Int32 index

    The index of the bookmark to remove.

    Implements

    System.Collections.Generic.IEnumerable<>
    System.Collections.IEnumerable
    IPdfBookMarkCollection

    See Also

    PdfBookMark
    Bookmarks
    ☀
    ☾
    Downloads
    • Download with Nuget
    • Start for Free
    In This Article
    Back to top
    Install with Nuget
    IronPDF_for_dotnet_log2o
    Blue key in circleGet started for FREE
    No credit card required
    Test in a live environment

    Test in production without watermarks.
    Works wherever you need it to.

    Fully-functional product

    Get 30 days of fully functional product.
    Have it up and running in minutes.

    24/5 technical support

    Full access to our support engineering team during your product trial

    Grey key in circleGet started for FREE
    The trial form was submitted successfully.
    Calendar in circleBook Free Live Demo
    No contact, no card details, no commitments Book a 30-minute, personal demo.
    Here's what to expect:

    A live demo of our product and its key features

    Get project specific feature recommendations

    All your questions are answered to make sure you have all the information you need. (No commitment whatsoever.)

    Grey key in circleBook Free Live Demo
    Your booking has been completed Check your e-mail for confirmation
    Support Team Member 6 related to The C# PDF Library Support Team Member 14 related to The C# PDF Library Support Team Member 4 related to The C# PDF Library Support Team Member 2 related to The C# PDF Library
    Online 24/5
    Need help? Our sales team would be glad to help you.
    Try the Enterprise Trial
    ironpdf_for_dotnet_log2o
    Key in blue circle
    Get your free 30-day Trial Key instantly.
    bullet_checkedNo credit card or account creation required
    Key in blue circle
    Get your free 30-day Trial Key instantly.
    Blue key in circleNo credit card or account creation required
    Green Check in orange circle
    The trial form was submitted successfully.
    badge_greencheck_in_yellowcircle
    Thank you for starting a trial

    Please check your email for the trial license key.

    If you don’t receive an email, please start a live chat or email support@ironsoftware.com

    Install with NuGet
    View Licensing
    • Logo Aetna
    • Logo NASA
    • Logo GE
    • Logo Porsche
    • Logo USDA
    • Logo Qatar
    Join Millions of Engineers who’ve tried IronPDF