Outlines & Bookmarks

IronPDF for Python can add a navigable bookmark outline to PDF documents, creating a table of contents panel that readers can use to jump directly to any section — including nested sub-sections.

Getting Started

Load or create a PdfDocument, then use the pdf.Bookmarks collection to add bookmark entries. Call AddBookMarkAtEnd to append entries to the bookmark list, or AddBookMarkAtStart on a child collection to nest sub-bookmarks beneath a parent.

Understanding the Code

  • pdf.Bookmarks.AddBookMarkAtEnd(title, pageIndex): Appends a new bookmark to the end of the top-level bookmark list. pageIndex is the zero-based page index the bookmark links to. Returns the new bookmark object.
  • bookmark.Children.AddBookMarkAtStart(title, pageIndex): Adds a child bookmark under an existing bookmark, creating a nested hierarchy. Returns the child bookmark object.
  • pdf.Bookmarks.AddBookMarkAtEnd("References", 20): Appends another bookmark after all existing entries.
  • SaveAs(path): Saves the document with all bookmarks embedded in the PDF outline.

Bookmark Hierarchy

PDF bookmarks support multiple nesting levels. Each bookmark returned by AddBookMarkAtEnd or AddBookMarkAtStart has its own .Children collection, allowing you to build trees of arbitrary depth.

Page Indexing

Bookmark page indexes are zero-based. Page 1 of the document is index 0, page 18 is index 17, and so on.

Ready to Get Started?
Version: 2026.6 just released
Still Scrolling Icon

Still Scrolling?

Want proof fast?
run a sample watch your HTML become a PDF.