Class PdfBookMark
Represents a single PDF bookmark (outline entry) for document navigation. Bookmarks appear in the sidebar of PDF readers, enabling quick jumps to specific pages.
Bookmarks form a hierarchical tree structure with parent-child relationships, allowing organized document navigation (e.g., chapters with sections).
Example - Create document outline:
var pdf = new ChromePdfRenderer().RenderHtmlAsPdf(htmlContent);
// Add top-level bookmarks:
var chapter1 = pdf.Bookmarks.AddBookMarkAtEnd("Chapter 1: Introduction", 0);
var chapter2 = pdf.Bookmarks.AddBookMarkAtEnd("Chapter 2: Getting Started", 5);
// Add nested bookmarks (sections):
chapter1.Children.AddBookMarkAtEnd("1.1 Overview", 0);
chapter1.Children.AddBookMarkAtEnd("1.2 Requirements", 2);
// Insert bookmark between existing ones:
chapter1.InsertBookMarkAfter("1.1a Quick Start", 1);
pdf.SaveAs("documented.pdf");
Inheritance
Namespace: IronPdf.Bookmarks
Assembly: IronPdf.dll
Syntax
public class PdfBookMark : Object, IPdfBookmark
Remarks
Key Properties:
Standards:
Properties
Bottom
Declaration
public int Bottom { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
Children
Gets the collection of child bookmarks nested under this bookmark. Use to create hierarchical navigation structures (chapters → sections → subsections).
Example:
var chapter = pdf.Bookmarks.AddBookMarkAtEnd("Chapter 1", 0);
chapter.Children.AddBookMarkAtEnd("Section 1.1", 1);
chapter.Children.AddBookMarkAtEnd("Section 1.2", 3);
Declaration
public IPdfBookMarkCollection Children { get; }
Property Value
| Type | Description |
|---|---|
| IPdfBookMarkCollection | Collection of nested bookmarks. Empty if no children exist. |
DestinationType
Gets the type of navigation destination for this bookmark. Default is Page (navigate to page).
Declaration
public virtual BookmarkDestinations DestinationType { get; }
Property Value
| Type | Description |
|---|---|
| BookmarkDestinations | The bookmark destination type. |
ItemId
Declaration
public string ItemId { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Left
Declaration
public int Left { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
NextBookmark
Gets the next sibling bookmark at the same hierarchical level.
Returns null if this is the last bookmark at this level.
Declaration
public IPdfBookmark NextBookmark { get; }
Property Value
| Type | Description |
|---|---|
| IronPdf.Bookmarks.IPdfBookmark | Next sibling bookmark, or null. |
PageIndex
Gets or sets the zero-based page index that this bookmark navigates to. Page 1 = index 0, Page 2 = index 1, etc.
Example:
// Navigate to page 5 (index 4):
bookmark.PageIndex = 4;
Declaration
public int PageIndex { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 | Zero-based page index (default: 0). |
Parent
Bookmark which contains this bookmark
Declaration
public IPdfBookmark Parent { get; }
Property Value
| Type | Description |
|---|---|
| IronPdf.Bookmarks.IPdfBookmark |
ParentText
Parent bookmark text
Declaration
public string ParentText { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
PreviousBookmark
Gets the previous sibling bookmark at the same hierarchical level.
Returns null if this is the first bookmark at this level.
Declaration
public IPdfBookmark PreviousBookmark { get; }
Property Value
| Type | Description |
|---|---|
| IronPdf.Bookmarks.IPdfBookmark | Previous sibling bookmark, or null. |
PreviousText
Previous bookmark text
Declaration
public string PreviousText { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String |
Right
Declaration
public int Right { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
Siblings
Gets the collection of sibling bookmarks at the same hierarchical level. Includes all bookmarks sharing the same parent, including this bookmark.
Declaration
public IPdfBookMarkCollection Siblings { get; }
Property Value
| Type | Description |
|---|---|
| IPdfBookMarkCollection | Collection of sibling bookmarks. |
Text
Gets or sets the display text shown in the PDF reader's bookmark panel. Use descriptive text like chapter titles, section names, or page descriptions.
Example:
bookmark.Text = "Chapter 3: Advanced Topics";
Declaration
public string Text { get; set; }
Property Value
| Type | Description |
|---|---|
| System.String | The bookmark display text. |
Top
Declaration
public int Top { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
Zoom
Declaration
public int Zoom { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
Methods
InsertBookMarkAfter(String, Int32)
Insert a new bookmark after the specified bookmark
Declaration
public IPdfBookmark InsertBookMarkAfter(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 |
InsertBookMarkBefore(String, Int32)
Insert a new bookmark after the specified bookmark
Declaration
public IPdfBookmark InsertBookMarkBefore(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 |