IRONSOFTWAREHOME
Outlines & Bookmarks

import com.ironsoftware.ironpdf.PdfDocument;
import com.ironsoftware.ironpdf.bookmark.Bookmark;
import com.ironsoftware.ironpdf.bookmark.BookmarkManager;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.List;

// Load an existing PDF from the file system (or create a new one from HTML)
PdfDocument pdf = PdfDocument.fromFile(Paths.get("assets/book.pdf"));

// Add top-level bookmarks to pages of the PDF using their page indices
BookmarkManager bookmarks = pdf.getBookmark();
bookmarks.addBookMarkAtEnd("Author's Note", 2);
bookmarks.addBookMarkAtEnd("Table of Contents", 3);
bookmarks.addBookMarkAtEnd("Summary", 10);
bookmarks.addBookMarkAtEnd("References", 12);

// Retrieve a reference to the Summary bookmark so that we can add a sublist of bookmarks to it.
List<Bookmark> bookmarkList = bookmarks.getBookmarks();
Bookmark bookmark = bookmarkList.get(2);
bookmark.AddChildBookmark("Conclusion", 11);

// Save the PDF to the filesystem
pdf.saveAs(Paths.get("assets/bookmarked.pdf"));
mvn install
Outlines & Bookmarks

Outlines & Bookmarks

Developers can use the BookmarkManager to add bookmarks to a PDF document. Access the BookmarkManager by calling the getBookmarks method on a PdfDocument.

In the featured code example, we call the addBookmarkAtEnd method to add four top-level bookmarks (one after another) to the working PdfDocument before saving the modifications to disk. Opening the modified PDF after executing the above code will show the bookmarks appearing in the order listed below:

  • Author's Note
  • Table of Contents
  • Summary
  • References

To prepend a bookmark, thus making it appear before other bookmarks if defined previously, you can use the addBookmarkAtStart method. For example, if the following line of code were placed right after the featured code example, it would make the bookmark "Foreword" appear before the first item in the previously mentioned list.

IronPDF has the ability to recognize bookmarks that have been added to the PDF using other third-party software. This gives the library considerable flexibility in terms of adding and modifying bookmarks in post-rendered PDF documents as required by the business.

For detailed information on working with bookmarks and other PDF functionalities, visit the IronPDF Overview Page on Iron Software to explore various features and integration possibilities.

Learn more about managing PDF bookmarks in Java
View on GitHub

Ready to Get Started?

Version:2026.8just released

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 Iron Suite
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
Java Maven Library for PDF
Install with Maven

Version: 2026.8

<dependency>
   <groupId>com.ironsoftware</groupId>
   <artifactId>ironpdf</artifactId>
   <version>2026.8.2</version>
</dependency>
https://central.sonatype.com/artifact/com.ironsoftware/ironpdf/2026.8.2
or
Java PDF JAR
Download JAR

Version: 2026.8

Manually install into your project