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");
Implements
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. |