IRONSOFTWAREHOME

How to Add PDF Bookmarks & Outlines in C# Using IronPDF

Curtis Chau
Curtis Chau
Updated: August 2, 2026

IronPDF enables you to add bookmarks (outlines) to PDF documents in C#, creating navigational aids similar to a Table of Contents. Add single or multi-layer bookmarks to enhance document usability and help users jump to key sections quickly. This feature works seamlessly across Windows, Linux, and macOS environments.

Quickstart: Adding Bookmarks to Your PDF in C#

Get started quickly with IronPDF by adding bookmarks to your PDF documents. This guide demonstrates how to load an existing PDF, add bookmarks for navigation, and save the updated document. Perfect for developers looking to enhance PDF functionality in their C# projects.

  1. 1Install IronPDF with NuGet Package Manager

    PM > Install-Package IronPdf

  2. 2Copy and run this code snippet.

    var pdf = new IronPdf.PdfDocument("example.pdf");
    pdf.Bookmarks.AddBookMarkAtEnd("Chapter 1", 1);
    pdf.SaveAs("bookmarked.pdf");
    C#
  3. 3Deploy to test on your live environment

    Start using IronPDF in your project today with a free trial
    arrow pointer

How Do I Work with PDF Bookmarks in C#?

In Adobe Acrobat Reader, outlines (also known as bookmarks) are displayed in the left sidebar, providing a convenient way to jump to key sections of the document. Bookmarks function as an interactive table of contents, allowing readers to navigate complex documents efficiently.

With IronPDF, you can import PDF documents and perform various operations on existing outlines, such as adding, reordering, editing properties, and deleting bookmarks. This gives you full control over the organization and structure of your PDF files, similar to how you can merge or split PDFs for document management.

Tips: All page indices follow zero-based indexing.

How Do I Add Single Layer Bookmarks?

Adding a bookmark in IronPDF is straightforward. Use the AddBookMarkAtEnd method, specifying the bookmark name and corresponding page index. This functionality integrates well with other PDF operations like adding headers and footers or setting custom margins to create professional documents. Below is an example:

using IronPdf;

// Create a new PDF or edit an existing document.
PdfDocument pdf = PdfDocument.FromFile("existing.pdf");

// Add a bookmark
pdf.Bookmarks.AddBookMarkAtEnd("NameOfBookmark", 0);

// Add a sub-bookmark
pdf.Bookmarks.AddBookMarkAtEnd("NameOfSubBookmark", 1);

pdf.SaveAs("singleLayerBookmarks.pdf");

The AddBookMarkAtEnd method appends bookmarks to the end of the existing bookmark list. For more control over bookmark placement, use AddBookMarkAtStart to insert bookmarks at the beginning of the list. Each bookmark references a specific page index, enabling precise navigation within the document.

Single-layer Bookmarks Document

How Do I Create Multi-Layer Bookmark Hierarchies?

IronPDF allows you to add bookmarks in a tree structure, which is particularly useful for maintaining navigability in large PDF documents. This feature is valuable when dealing with extensive collections of examination papers, sales reports, or receipt records from various dates and locations in a single PDF document. Like how you might create PDF forms for data collection, structured bookmarks help organize complex information hierarchically.

The AddBookMarkAtEnd method returns a IPdfBookMark object, allowing you to add child bookmarks. For example, use Children.AddBookMarkAtStart("Date1", 0) or Children.AddBookMarkAtEnd("Date1", 0) to add child bookmarks to the "Examination" bookmark. This nested structure creates a hierarchical organization that mirrors your document's logical flow. The following code demonstrates this concept:

using IronPdf;

// Load existing PDF document
PdfDocument pdf = PdfDocument.FromFile("examinationPaper.pdf");

// Assign IPdfBookMark object to a variable
var mainBookmark = pdf.Bookmarks.AddBookMarkAtEnd("Examination", 0);

// Add bookmark for days
var date1Bookmark = mainBookmark.Children.AddBookMarkAtStart("Date1", 1);

// Add bookmark for type of test
var paperBookmark = date1Bookmark.Children.AddBookMarkAtStart("Paper", 1);
paperBookmark.Children.AddBookMarkAtEnd("PersonA", 3);
paperBookmark.Children.AddBookMarkAtEnd("PersonB", 4);

// Add bookmark for days
var date2Bookmark = mainBookmark.Children.AddBookMarkAtEnd("Date2", 5);

// Add bookmark for type of test
var computerBookmark = date2Bookmark.Children.AddBookMarkAtStart("Computer", 5);
computerBookmark.Children.AddBookMarkAtEnd("PersonC", 6);
computerBookmark.Children.AddBookMarkAtEnd("PersonD", 7);

pdf.SaveAs("multiLayerBookmarks.pdf");

This hierarchical approach is particularly valuable when working with complex documents that require detailed organization. The nested structure allows users to expand and collapse bookmark sections, making navigation intuitive even in documents with hundreds of pages.

Multi-layer Bookmarks Document

How Do I Auto-Generate Bookmarks from HTML Headings?

When rendering HTML to PDF, IronPDF can automatically build a hierarchical bookmark outline from the document's heading structure (h1-h6) or any custom CSS selectors. This removes the need to manually call AddBookMarkAtEnd for each section.

Enable the feature with the AutoBookmarksFromHeadings property on RenderingOptions before calling RenderHtmlAsPdf or RenderUrlAsPdf:

using IronPdf;

var renderer = new ChromePdfRenderer();

// Master switch: auto-generate bookmarks from HTML headings (h1-h6) during rendering
renderer.RenderingOptions.AutoBookmarksFromHeadings = true;

var html = @"
<h1>Annual Report</h1>
<h2>Executive Summary</h2>
<p>Overview of the year.</p>
<h2>Financial Results</h2>
<h3>Revenue</h3>
<h3>Expenses</h3>
<h2>Outlook</h2>
<p>Looking forward.</p>";

var pdf = renderer.RenderHtmlAsPdf(html);

// pdf.Bookmarks is already populated with a hierarchical outline matching the heading structure
pdf.SaveAs("auto-bookmarked.pdf");

The following properties control which elements are bookmarked:

  • AutoBookmarksFromHeadings (bool, default false): Turn the feature on. When set to true, IronPDF builds a bookmark outline from your HTML headings automatically.
  • AutoBookmarkMinHeadingLevel (int, default 1): The highest-level heading to start from. Set to 1 to include h1 (the top of the document).
  • AutoBookmarkMaxHeadingLevel (int, default 6): The deepest heading level to include. Set to 3 to bookmark only h1, h2, and h3 - ignoring h4 through h6.
  • AutoBookmarkCssSelectors (string[], default null): Use custom CSS selectors instead of heading tags. For example: ".chapter-title" or "[data-bookmark]".

Customizing Heading Levels and CSS Selectors

To restrict bookmarks to top-level headings only:

renderer.RenderingOptions.AutoBookmarksFromHeadings = true;
renderer.RenderingOptions.AutoBookmarkMaxHeadingLevel = 3;

To bookmark custom elements instead of headings, supply CSS selectors:

renderer.RenderingOptions.AutoBookmarksFromHeadings = true;
renderer.RenderingOptions.AutoBookmarkCssSelectors = new[]
{
    "h1",
    ".chapter-title",
    "[data-bookmark]"
};

How Do I Query the Rendered Location of HTML Elements?

After rendering, IronPDF can report exactly which page and coordinates a given HTML element ended up on. This replaces the older workaround of rendering first, extracting text, and searching pages manually.

Set ElementQuerySelectors on RenderingOptions before rendering, then call GetElementLocations on the resulting PdfDocument:

using IronPdf;
using System;

var renderer = new ChromePdfRenderer();

// Configure which elements should be queryable after rendering
renderer.RenderingOptions.ElementQuerySelectors = new[] { "h1", ".kpi-card" };

var html = @"
<h1>Q4 Dashboard</h1>
<div class='kpi-card'>Revenue: $1.2M</div>
<div class='kpi-card'>Growth: 18%</div>
<h1>Q3 Comparison</h1>
<div class='kpi-card'>Previous: $1.0M</div>";

var pdf = renderer.RenderHtmlAsPdf(html);

// Retrieve the rendered page location of each matched element
foreach (var location in pdf.GetElementLocations())
{
    Console.WriteLine($"'{location.Text}' on page {location.PageIndex + 1} " +
                      $"at ({location.Rectangle.X}, {location.Rectangle.Y})");
}

pdf.SaveAs("dashboard.pdf");

GetElementLocations returns a List<RenderedElementLocation> containing one entry per matched element:

PropertyTypeWhat it tells you
TextstringThe text inside the element.
PageIndexintWhich page the element ended up on (starts at 0).
RectangleIronSoftware.Drawing.RectangleThe element's position on the page, in PDF points (1/72 inch). Origin is bottom-left.
ElementIndexintThe element's order in the original HTML (starts at 0).
Tips: Results are cached on first call. If you modify the document's annotations after rendering and need fresh coordinates, call ResetElementLocationCache to force a re-scan on the next GetElementLocations call.

Combining Auto-Bookmarks with Element Location Tracking

Auto-bookmarks and element location queries can be combined in a single render. For example, generating an outline from h1/h2 headings while tracking the page location of .invoice-total elements:

using IronPdf;
using System;

var renderer = new ChromePdfRenderer();

// Auto-generate bookmarks from top-level headings only
renderer.RenderingOptions.AutoBookmarksFromHeadings = true;
renderer.RenderingOptions.AutoBookmarkMaxHeadingLevel = 2;

// Also track the page location of invoice totals after rendering
renderer.RenderingOptions.ElementQuerySelectors = new[] { ".invoice-total" };

var html = @"
<h1>Invoice #2026-001</h1>
<h2>Line Items</h2>
<p>Services rendered for Q1.</p>
<p class='invoice-total'>Subtotal: $4,500.00</p>
<h1>Invoice #2026-002</h1>
<h2>Line Items</h2>
<p>Consulting hours for Q2.</p>
<p class='invoice-total'>Subtotal: $7,200.00</p>";

var pdf = renderer.RenderHtmlAsPdf(html);

// Bookmarks are populated automatically; locations can be queried after rendering
foreach (var location in pdf.GetElementLocations())
{
    Console.WriteLine($"{location.Text} appears on page {location.PageIndex + 1}");
}

pdf.SaveAs("invoices.pdf");

How Can I Retrieve and Navigate Existing Bookmarks?

IronPDF makes it easy to retrieve and view bookmarks in a PDF document. Navigating through the bookmark tree is straightforward and provides seamless access to different sections. This functionality is essential when working with existing PDFs that need editing or when implementing features like searching and replacing text within bookmarked sections. Consider the multi-layer bookmarks document example above.

The "Examination" bookmark has a Children property that points to the "Date1" and "Date2" bookmarks. The "Date1" bookmark has a NextBookmark property that points to the "Date2" bookmark. Additionally, the "Date1" bookmark has a Children property containing the "Paper" bookmark. This interconnected structure allows for sophisticated navigation patterns and document organization.

To retrieve all bookmarks in the opened PDF document, use the GetAllBookmarks method. This provides a comprehensive list of all bookmarks, allowing you to analyze and utilize the bookmark structure:

using IronPdf;

// Load existing PDF document
PdfDocument pdf = PdfDocument.FromFile("multiLayerBookmarks.pdf");

// Retrieve bookmarks list
var mainBookmark = pdf.Bookmarks.GetAllBookmarks();
Please note: Merging two PDF documents with identical bookmark names can disrupt the bookmark list.
Warning: Only bookmarks created from page indices are supported. Bookmarks from other PDF elements will have their page index value set to -1.

Learn how to create a Table of Contents when generating PDF from HTML in the following article: "Creating a Table of Contents with IronPDF."

Ready to see what else you can do? Check out our tutorial page here: Organize PDFs

Frequently Asked Questions

What is the purpose of adding PDF bookmarks using IronPDF?

Adding PDF bookmarks with IronPDF creates navigational aids similar to a Table of Contents, enhancing document usability by allowing users to jump to key sections quickly. This is beneficial for navigating complex documents efficiently.

How can I add single-layer bookmarks in a PDF using IronPDF?

In IronPDF, you can add single-layer bookmarks using the `AddBookMarkAtEnd` method. This requires specifying the bookmark name and corresponding page index, facilitating precise navigation within the document.

Can I create multi-layer bookmark hierarchies with IronPDF?

Yes, IronPDF allows the creation of multi-layer bookmark hierarchies using the `AddBookMarkAtEnd` method. This feature lets you organize bookmarks in a tree structure, useful for maintaining navigability in large documents.

Is it possible to auto-generate bookmarks from HTML headings with IronPDF?

IronPDF can automatically create a hierarchical bookmark outline from an HTML document's heading structure during conversion to PDF. This feature is enabled using the `AutoBookmarksFromHeadings` property in `RenderingOptions`.

Can I customize which elements are auto-bookmarked in IronPDF?

Yes, you can customize auto-bookmarking in IronPDF by setting properties like `AutoBookmarkMinHeadingLevel`, `AutoBookmarkMaxHeadingLevel`, and `AutoBookmarkCssSelectors` to define which HTML elements should be converted into bookmarks.

How do I retrieve and navigate existing bookmarks in a PDF with IronPDF?

You can retrieve and navigate existing bookmarks in a PDF using IronPDF's `GetAllBookmarks` method, which provides a comprehensive list of all bookmarks, allowing for easy navigation and organization analysis.

Does IronPDF support bookmark manipulation in existing PDF documents?

Yes, IronPDF allows for various operations on existing PDF outlines such as adding, reordering, editing properties, and deleting bookmarks, giving you full control over the PDF document's structure.

What environments does IronPDF support for adding bookmarks to PDFs?

IronPDF supports adding bookmarks to PDFs on Windows, Linux, and macOS environments, providing cross-platform compatibility for developers.

Can IronPDF track the rendered locations of HTML elements in a PDF?

IronPDF can report the rendered page and coordinates of specific HTML elements in a PDF using the `GetElementLocations` method, helping developers precisely locate elements within the PDF document.

What are the key steps to get started with adding bookmarks in IronPDF?

The key steps to add bookmarks in IronPDF include downloading IronPDF from NuGet, loading or rendering a new PDF document, adding single or multi-layer bookmarks, and saving the updated document.

Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...
Read More

Ready to Get Started?

Nuget Downloads 21,039,986Version:2026.9just released

Get your FREE

30-day Trial Key instantly.

bullet_checkedNo credit card or account creation required
bullet_testTest in production
without watermarks
bullet_calendar30 days fully
functional product
bullet_support24/5 technical
support during trial
Get your free 30-day Trial Key instantly.
No credit card or account creation required
C# NuGet Library for PDF
Install with NuGet

Version: 2026.9

PM > Install-Package IronPdf
nuget.org/packages/IronPdf/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronPdf"
  3. Select the package and install
C# PDF DLL
Download DLL

Version: 2026.9

or download Windows Installer here.

  1. Download and unzip IronPDF to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronPdf.dll"

Licenses from $999

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

OR
bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required
C# NuGet Library for PDF
Install with NuGet

Version: 2026.9

PM > Install-Package IronPdf
nuget.org/packages/IronPdf/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronPdf"
  3. Select the package and install
C# PDF DLL
Download DLL

Version: 2026.9

or download Windows Installer here.

  1. Download and unzip IronPDF to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronPdf.dll"

Licenses from $999