How to Add PDF Bookmarks & Outlines in C# Using IronPDF
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.
Get started making PDFs with NuGet now:
Install IronPDF with NuGet Package Manager
Copy and run this code snippet.
var pdf = new IronPdf.PdfDocument("example.pdf"); pdf.Bookmarks.AddBookMarkAtEnd("Chapter 1", 1); pdf.SaveAs("bookmarked.pdf");Deploy to test on your live environment
Minimal Workflow (5 steps)
- Download IronPDF from NuGet
- Load existing or render new PDF document
- Add single-layer bookmarks to jump to key sections
- Add multi-layer bookmarks for hierarchical organization
- Retrieve and view bookmark properties
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.
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:
:path=/static-assets/pdf/content-code-examples/how-to/bookmarks-single-layer-bookmark.csusing 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 an 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:
:path=/static-assets/pdf/content-code-examples/how-to/bookmarks-multi-layer-bookmark.csusing 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 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:
:path=/static-assets/pdf/content-code-examples/how-to/bookmarks-retrieve-bookmark.csusing IronPdf;
// Load existing PDF document
PdfDocument pdf = PdfDocument.FromFile("multiLayerBookmarks.pdf");
// Retrieve bookmarks list
var mainBookmark = pdf.Bookmarks.GetAllBookmarks();-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
How do I add bookmarks to a PDF document in C#?
IronPDF makes it easy to add bookmarks to PDF documents in C#. You can use the AddBookmarkAtEnd method to add single-layer bookmarks by specifying the bookmark name and page index. For example: pdf.Bookmarks.AddBookMarkAtEnd("Chapter 1", 1). This creates navigational aids similar to a table of contents that help users jump to key sections quickly.
What's the difference between AddBookmarkAtEnd and AddBookmarkAtStart methods?
IronPDF provides two methods for bookmark placement. The AddBookMarkAtEnd method appends bookmarks to the end of the existing bookmark list, while AddBookMarkAtStart inserts bookmarks at the beginning of the list. Both methods reference specific page indices for precise navigation within the document.
Can I create hierarchical bookmark structures with multiple levels?
Yes, IronPDF allows you to create multi-layer bookmark hierarchies in a tree structure. This is particularly useful for organizing complex documents with nested sections, similar to how you would structure a detailed table of contents with chapters and sub-chapters.
Is bookmark functionality compatible across different operating systems?
IronPDF's bookmark feature works seamlessly across Windows, Linux, and macOS environments. You can add, edit, and manage PDF bookmarks regardless of your operating system, ensuring consistent functionality across different platforms.
What operations can I perform on existing PDF bookmarks?
With IronPDF, you can perform various operations on existing PDF outlines including adding new bookmarks, reordering them, editing bookmark properties, and deleting unwanted bookmarks. This gives you full control over the organization and structure of your PDF files.
How are bookmarks displayed when users open the PDF?
In Adobe Acrobat Reader and similar PDF viewers, bookmarks created with IronPDF appear as outlines in the left sidebar. They function as an interactive table of contents, allowing readers to navigate complex documents efficiently by clicking to jump to specific sections.






