Table of Contents  show  
Bookmarks are a useful way to outline the structure of a PDF file, acting like a table of contents.
Many viewers will display bookmarks in a panel alongside the document which allows users to navigate between different pages.
Our PDF SDK, JPedal, provides an API to create bookmarks programmatically.
You can create arbitrarily complex bookmark structures and add them to any PDF file using the following code:
final PdfManipulator pdf = new PdfManipulator();
pdf.loadDocument(new File("inputFile.pdf"));
final Bookmarks root = new Bookmarks();
final Bookmark b = root.addChild("1", 1)
        .addChild("1.1", 2)
        .addChild("1.1.1", 3);
b.addChild("1.1.1.a", 4);
b.addChild("1.1.1.b", 5);
b.addChild("1.1.1.c", 6);
Bookmark b2 = b.addChild("1.1.1.d", 7);
b2.addChild("1.1.1.d.A", 8);
b2.addChild("1.1.1.d.B", 9);
root.addChild("2", 11)
        .addChild("2.1", 13);
pdf.addBookmarks(root);
pdf.apply();
pdf.writeDocument(new File("outputFile.pdf"));
pdf.closeDocument();
Warning, calling the addBookmarks() method will erase any existing bookmarks.
Download JPedal
You can get a JPedal trial jar to test adding bookmarks to PDF files.
Learn more
Learn more about the PDF Manipulator API.
We can help you better understand the PDF format as developers who have been working with the format for more than 2 decades!