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
.
// Assume we have a PdfDocument instance named pdf
BookmarkManager bookmarks = pdf.getBookmarks();
// Assume we have a PdfDocument instance named pdf
BookmarkManager bookmarks = pdf.getBookmarks();
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 Content
- 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.
// Add a bookmark at the start of the existing list
bookmarks.addBookmarkAtStart("Foreword", 1);
// Add a bookmark at the start of the existing list
bookmarks.addBookmarkAtStart("Foreword", 1);
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.