java.lang.Object
com.aspose.words.BookmarksOutlineLevelCollection
public class BookmarksOutlineLevelCollection
Key is a case-insensitive string bookmark name. Value is a int bookmark outline level. Bookmark outline level may be a value from 0 to 9. Specify 0 and Word bookmark will not be displayed in the document outline.
Specify 1 and Word bookmark will be displayed in the document outline at level 1; 2 for level 2 and so on.
| Constructor Summary |
|---|
BookmarksOutlineLevelCollection()
|
| Property Getters/Setters Summary | ||
|---|---|---|
int | getCount() | |
| Gets the number of elements contained in the collection. | ||
int | get(int index) | |
void | set(int index, int value) | |
| Gets or sets a bookmark outline level at the specified index. | ||
int | get(java.lang.String name) | |
void | set(java.lang.String name, int value) | |
| Gets or a sets a bookmark outline level by the bookmark name. | ||
| Method Summary | ||
|---|---|---|
void | add(java.lang.String name, int outlineLevel) | |
| Adds a bookmark to the collection. | ||
void | clear() | |
| Removes all elements from the collection. | ||
boolean | contains(java.lang.String name) | |
| Determines whether the collection contains a bookmark with the given name. | ||
int | indexOfKey(java.lang.String name) | |
| Returns the zero-based index of the specified bookmark in the collection. | ||
java.util.Iterator<java.util.Map.Entry<java.lang.String, int>> | iterator() | |
void | remove(java.lang.String name) | |
| Removes a bookmark with the specified name from the collection. | ||
void | removeAt(int index) | |
| Removes a bookmark at the specified index. | ||
| Constructor Detail |
|---|
public BookmarksOutlineLevelCollection()
| Property Getters/Setters Detail |
|---|
getCount | |
public int getCount() | |
get/set | |
public int get(int index) / public void set(int index, int value) | |
index - Zero-based index of the bookmark.get/set | |
public int get(java.lang.String name) / public void set(java.lang.String name, int value) | |
name - Case-insensitive name of the bookmark.| Method Detail |
|---|
add | |
public void add(java.lang.String name, int outlineLevel) | |
name - The case-insensitive name of the bookmark to add.outlineLevel - The outline level of the bookmark. Valid range is 0 to 9.Example:
Shows how adding bookmarks outlines with whitespaces(pdf, xps)
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Add bookmarks with whitespaces. MS Word formats (like doc, docx) does not support bookmarks with whitespaces by default
// and all whitespaces in the bookmarks were replaced with underscores. If you need to use bookmarks in PDF or XPS outlines, you can use them with whitespaces.
builder.startBookmark("My Bookmark");
builder.writeln("Text inside a bookmark.");
builder.startBookmark("Nested Bookmark");
builder.writeln("Text inside a NestedBookmark.");
builder.endBookmark("Nested Bookmark");
builder.writeln("Text after Nested Bookmark.");
builder.endBookmark("My Bookmark");
// Specify bookmarks outline level. If you are using xps format, just use XpsSaveOptions.
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
pdfSaveOptions.getOutlineOptions().getBookmarksOutlineLevels().add("My Bookmark", 1);
pdfSaveOptions.getOutlineOptions().getBookmarksOutlineLevels().add("Nested Bookmark", 2);
doc.save(getMyDir() + "\\Artifacts\\Bookmarks.WhiteSpaces.pdf", pdfSaveOptions);clear | |
public void clear() | |
contains | |
public boolean contains(java.lang.String name) | |
name - Case-insensitive name of the bookmark to locate.indexOfKey | |
public int indexOfKey(java.lang.String name) | |
name - The case-insensitive name of the bookmark.iterator | |
public java.util.Iterator<java.util.Map.Entry<java.lang.String, int>> iterator() | |
remove | |
public void remove(java.lang.String name) | |
name - The case-insensitive name of the bookmark.removeAt | |
public void removeAt(int index) | |
index - The zero based index.