Export Bookmarks to XML from an Existing PDF File (facades)
Contents
[
Hide
]
The exportBookmarksToXml method allows you to export bookmarks from a PDF file to an XML file.
To export bookmarks:
- Create a PdfBookmarkEditor object and bind the PDF file using the bindPdf method.
- Call the exportBookmarksToXml method.
The following code snippet shows you how to export bookmarks to an XML file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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(); |