Export Bookmarks to XML from an Existing PDF File (facades)

Contents
[ ]

To export bookmarks:

  1. Create a PdfBookmarkEditor object and bind the PDF file using the bindPdf method.
  2. Call the exportBookmarksToXml method.

The following code snippet shows you how to export bookmarks to an XML file.

// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-Java
// Create PdfBookmarkEditor object
PdfBookmarkEditor bookmarkEditor = new PdfBookmarkEditor();
// Open PDF file
bookmarkEditor.bindPdf("Input.pdf");
// Export bookmarks
bookmarkEditor.exportBookmarksToXML("bookmarks.xml");
bookmarkEditor.dispose();

From Aspose.PDF for Java 9.0.0, the PdfBookmarkEditor class implements the exportBookmarksToXML and importBookmarksWithXML methods with Stream arguments. As a result, extracted bookmarks can be saved to a stream object.

// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.Pdf-for-Java
// Create PdfBookmarkEditor object
PdfBookmarkEditor bookmarkeditor = new PdfBookmarkEditor();
// Open PDF file
bookmarkeditor.bindPdf("Input.pdf");
OutputStream os = new FileOutputStream("bookmark.xml");
bookmarkeditor.exportBookmarksToXML(os);
bookmarkeditor.dispose();