Create Bookmarks of All Pages (facades)

Create Bookmarks of All Pages (facades)

In order to create bookmarks of all the pages, you need to use createBookmarks method without any parameters . PdfBookmarEditor class allows you to create bookmarks of all the pages of a PDF file. First, you need to create an object of PdfBookmarkEditor class and bind the input PDF using bindPdf method. Then, you have to call createBookmarks method and save the output PDF file using save method.

The following code snippet shows you:

// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-Java
// open document
PdfBookmarkEditor bookmarkEditor = new PdfBookmarkEditor();
bookmarkEditor.bindPdf("Input.pdf");
// create bookmark of all pages
bookmarkEditor.createBookmarks();
// save updated PDF file
bookmarkEditor.save("Output.pdf");

Create Bookmarks of All Pages with Properties (facades)

PdfBookmarEditor class allows you to create bookmarks of all the pages of a PDF file and specify the properties (Color, Bold, Italic). You can do that with the help of createBookmarks method. First, you need to create an object of PdfBookmarkEditor class and bind the input PDF using bindPdf method. Then, you have to call createBookmarks method and save the output PDF file using save method.

The following code snippet shows you how to create bookmarks of all the pages with properties.

// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-Java
// Path to Directorty
String myDir = "PathToDir";
// open document
PdfBookmarkEditor bookmarkEditor = new PdfBookmarkEditor();
bookmarkEditor.bindPdf("Input.pdf");
// create bookmark of all pages
bookmarkEditor.createBookmarks(Color.GREEN, true, true);
// save updated PDF file
bookmarkEditor.save(myDir + "Output.pdf");