从现有PDF文件导出书签到XML(外观)
Contents
[
Hide
]
exportBookmarksToXml方法允许您将PDF文件中的书签导出到XML文件。
要导出书签:
- 创建一个PdfBookmarkEditor对象,并使用bindPdf方法绑定PDF文件。
- 调用exportBookmarksToXml方法。
以下代码片段展示了如何将书签导出到XML文件。
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(); |
从 Aspose.PDF for Java 9.0.0 开始,PdfBookmarkEditor 类实现了带有 Stream 参数的 exportBookmarksToXML 和 importBookmarksWithXML 方法。因此,提取的书签可以保存到流对象中。
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(); |