public final class PdfBookmarkEditor extends SaveableFacade
Represents a class to work with PDF file's bookmarks including create, modify, export, import and delete.
| Constructor and Description |
|---|
PdfBookmarkEditor()
Initializes new
PdfBookmarkEditor object. |
PdfBookmarkEditor(IDocument document)
Initializes new
PdfBookmarkEditor object on base of the document. |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the instance of PdfBookmarkEditor and release the resources.
|
void |
createBookmarkOfPage(String[] bookmarkName,
int[] pageNumber)
Creates bookmarks for the specified pages.
|
void |
createBookmarkOfPage(String bookmarkName,
int pageNumber)
Creates bookmark for the specified page.
|
void |
createBookmarks()
Creates bookmarks for all pages.
|
void |
createBookmarks(Bookmark bookmark)
Creates the specified bookmark in the document.
|
void |
createBookmarks(Color color,
boolean boldFlag,
boolean italicFlag)
Create bookmarks for all pages with specified color and style (bold, italic).
|
void |
deleteBookmarks()
Deletes all bookmarks of the PDF document.
|
void |
deleteBookmarks(String title)
Deletes the bookmark of the PDF document.
|
static void |
exportBookmarksToHtml(String inPdfFile,
String outHtmlFile)
Exports bookmarks to HTML file.
|
void |
exportBookmarksToXML(OutputStream output)
Exports bookmarks to XML stream.
|
void |
exportBookmarksToXML(String xmlFile)
Exports bookmarks to XML file.
|
Bookmarks |
extractBookmarks()
Extracts bookmarks of all levels from the document.
|
Bookmarks |
extractBookmarks(Bookmark bookmark)
Extracts the children of a bookmark with a title like in specified bookamrk.
|
Bookmarks |
extractBookmarks(boolean upperLevel)
Extracts bookmarks of all levels from the document.
|
Bookmarks |
extractBookmarks(String title)
Extracts the bookmarks with the specified title.
|
void |
extractBookmarksToHTML(String pdfFile,
String cssFile)
Deprecated.
|
void |
importBookmarksWithXML(InputStream stream)
Imports bookmarks to the document from XML file.
|
void |
importBookmarksWithXML(String xmlFile)
Imports bookmarks to the document from XML file.
|
void |
modifyBookmarks(String sTitle,
String dTitle)
Modifys bookmark title according to the specified bookmark title.
|
save, savebindPdf, bindPdf, bindPdf, bindPdf, bindPdf, dispose, getDocumentpublic PdfBookmarkEditor()
Initializes new PdfBookmarkEditor object.
public PdfBookmarkEditor(IDocument document)
Initializes new PdfBookmarkEditor object on base of the document.
document - Pdf document.public void createBookmarks()
Creates bookmarks for all pages.
PdfBookmarkEditor editor = new PdfBookmarkEditor();
editor.bindPdf("example.pdf");
editor.createBookmarks();
editor.save("example_out.pdf");
public void createBookmarkOfPage(String bookmarkName, int pageNumber)
Creates bookmark for the specified page.
PdfBookmarkEditor editor = new PdfBookmarkEditor();
editor.bindPdf("example.pdf");
editor.createBookmarkOfPage("bookmark for page 1", 1);
editor.save("example_out.pdf");
bookmarkName - The specified bookmark name.pageNumber - The specified desination page.public void createBookmarks(Bookmark bookmark)
Creates the specified bookmark in the document. The method can be used for forming nested bookmarks hierarchy.
PdfBookmarkEditor editor = new PdfBookmarkEditor();
editor.bindPdf("example.pdf");
Bookmark bm1=new Bookmark();
bm1.setPageNumber(1);
bm1.setTitle("First child");
Bookmark bm2=new Bookmark();
bm2.setPageNumber(2);
bm2.setTitle("Second child");
Bookmark bm=new Bookmark();
bm.setAction=(GoTo");
bm.setPageNumber(1);
bm.setTitle("Parent");
Bookmarks bms=new Bookmarks();
bms.add(bm1);
bms.add(bm2);
bm.setChildItem(bms);
editor.setCreateBookmarks(bm);
editor.save("example_out.pdf");
bookmark - The bookmark will be added to the document.public void createBookmarks(Color color, boolean boldFlag, boolean italicFlag)
Create bookmarks for all pages with specified color and style (bold, italic).
PdfBookmarkEditor editor = new PdfBookmarkEditor();
editor.bindPdf("example.pdf");
editor.createBookmarks(System.Drawing.Color.Red, true, true);
editor.save("example_out.pdf");
color - The color of title.boldFlag - The flag of bold attribution.italicFlag - The flag of italic attribution.public void createBookmarkOfPage(String[] bookmarkName, int[] pageNumber)
Creates bookmarks for the specified pages.
PdfBookmarkEditor editor = new PdfBookmarkEditor();
editor.bindPdf("example.pdf");
editor.createBookmarkOfPage("bookmark for page 1", 1);
editor.save("example_out.pdf");
bookmarkName - Bookmarks title array.pageNumber - Bookmarks desination page array.public void deleteBookmarks()
Deletes all bookmarks of the PDF document.
PdfBookmarkEditor editor = new PdfBookmarkEditor();
editor.bindPdf("example.pdf");
editor.deleteBookmarks();
editor.save("example_out.pdf");
public void deleteBookmarks(String title)
Deletes the bookmark of the PDF document.
PdfBookmarkEditor editor = new PdfBookmarkEditor();
editor.bindPdf("example.pdf");
editor.deleteBookmarks("existing bookmark title");
editor.save("example_out.pdf");
title - The title of bookmark deleted.public void modifyBookmarks(String sTitle, String dTitle)
Modifys bookmark title according to the specified bookmark title.
PdfBookmarkEditor editor = new PdfBookmarkEditor();
editor.bindPdf("example.pdf");
editor.modifyBookmarks("existing bookmark title", "new bookmark title");
editor.save("example_out.pdf");
sTitle - Source bookmark title.dTitle - Modified bookmark title.public Bookmarks extractBookmarks()
Extracts bookmarks of all levels from the document.
PdfBookmarkEditor editor = new PdfBookmarkEditor();
editor.bindPdf("example.pdf");
Bookmarks bms = editor.ExtractBookmarks();
for(Bookmark bm : bms)
System.out.println(bm.Title);
public Bookmarks extractBookmarks(boolean upperLevel)
Extracts bookmarks of all levels from the document.
upperLevel - If true, extracts only upper level bookmarks. Else, extracts all bookmarks recursively.public Bookmarks extractBookmarks(String title)
Extracts the bookmarks with the specified title.
PdfBookmarkEditor editor = new PdfBookmarkEditor();
editor.bindPdf("example.pdf");
Bookmarks bms = editor.ExtractBookmarks("Title");
for(Bookmark bm : (Iterable<Bookmark>)bms)
System.out.println(bm.Title);
title - Extracted item title.public Bookmarks extractBookmarks(Bookmark bookmark)
Extracts the children of a bookmark with a title like in specified bookamrk.
PdfBookmarkEditor editor = new PdfBookmarkEditor();
editor.bindPdf("example.pdf");
Bookmark bookmark = new Bookmark();
bookmark.setTitle ( "Title");
Bookmarks bms = editor.ExtractBookmarks(bookmark);
for(Bookmark bm : (Iterable<Bookmark>)bms)
System.out.println(bm.Title);
bookmark - The specified bookamrk.@Deprecated public void extractBookmarksToHTML(String pdfFile, String cssFile)
Exports bookmarks to HTML file.
PdfBookmarkEditor editor = new PdfBookmarkEditor();
editor.extractBookmarksToHTML("example.pdf", null);
pdfFile - The PDF file which bookmarks will be exported.cssFile - The CSS file to display HTML file, can be null.public void exportBookmarksToXML(String xmlFile)
Exports bookmarks to XML file.
PdfBookmarkEditor editor = new PdfBookmarkEditor();
editor.bindPdf("example.pdf");
editor.exportBookmarksToXML("bookmarks.xml");
xmlFile - The output XML file.public void exportBookmarksToXML(OutputStream output)
Exports bookmarks to XML stream.
output - Output stream where data will be stored.public void importBookmarksWithXML(String xmlFile)
Imports bookmarks to the document from XML file.
PdfBookmarkEditor editor = new PdfBookmarkEditor();
editor.bindPdf("example.pdf");
editor.importBookmarksWithXML("bookmarks.xml");
editor.save("example_out.pdf");
xmlFile - The XML file containing bookmarks list.public void importBookmarksWithXML(InputStream stream)
Imports bookmarks to the document from XML file.
stream - Stream with bookmarks data.public static void exportBookmarksToHtml(String inPdfFile, String outHtmlFile)
Exports bookmarks to HTML file.
PdfBookmarkEditor.extractBookmarksToHTML("example.pdf", "bookmarks.html");
inPdfFile - Input PDF file which bookmarks will be exported.outHtmlFile - Output HTML fileCopyright © 2025 Aspose. All Rights Reserved.