java.lang.Object
com.aspose.words.Bookmark
public class Bookmark
- extends java.lang.Object
Represents a single bookmark.
Bookmark is a "facade" object that encapsulates two nodes BookmarkStart
and BookmarkEnd in a document tree and allows to work with a bookmark as a single object.
Example:
Shows how to get or set bookmark name and text.
Document doc = new Document(getMyDir() + "Bookmark.doc");
// Use the indexer of the Bookmarks collection to obtain the desired bookmark.
Bookmark bookmark = doc.getRange().getBookmarks().get("MyBookmark");
// Get the name and text of the bookmark.
String name = bookmark.getName();
String text = bookmark.getText();
// Set the name and text of the bookmark.
bookmark.setName("RenamedBookmark");
bookmark.setText("This is a new bookmarked text.");
Property Getters/Setters Summary |
BookmarkEnd | getBookmarkEnd() | |
|
Gets the node that represents the end of the bookmark.
|
BookmarkStart | getBookmarkStart() | |
|
Gets the node that represents the start of the bookmark.
|
java.lang.String | getName() | |
void | setName(java.lang.String value) | |
|
Gets or sets the name of the bookmark.
|
java.lang.String | getText() | |
void | setText(java.lang.String value) | |
|
Gets or sets the text enclosed in the bookmark.
|
Method Summary |
void | remove() | |
Removes the bookmark from the document. Does not remove text inside the bookmark.
|
Property Getters/Setters Detail |
-
Gets the node that represents the end of the bookmark.
-
Gets the node that represents the start of the bookmark.
getName/setName | |
public java.lang.String getName() / public void setName(java.lang.String value)
|
-
Gets or sets the name of the bookmark.
Note that if you change the name of a bookmark to a name that already exists in the document,
no error will be given and only the first bookmark will be stored when you save the document.
Example:
Shows how to get or set bookmark name and text.
Document doc = new Document(getMyDir() + "Bookmark.doc");
// Use the indexer of the Bookmarks collection to obtain the desired bookmark.
Bookmark bookmark = doc.getRange().getBookmarks().get("MyBookmark");
// Get the name and text of the bookmark.
String name = bookmark.getName();
String text = bookmark.getText();
// Set the name and text of the bookmark.
bookmark.setName("RenamedBookmark");
bookmark.setText("This is a new bookmarked text.");
getText/setText | |
public java.lang.String getText() / public void setText(java.lang.String value)
|
-
Gets or sets the text enclosed in the bookmark.
Example:
Shows how to get or set bookmark name and text.
Document doc = new Document(getMyDir() + "Bookmark.doc");
// Use the indexer of the Bookmarks collection to obtain the desired bookmark.
Bookmark bookmark = doc.getRange().getBookmarks().get("MyBookmark");
// Get the name and text of the bookmark.
String name = bookmark.getName();
String text = bookmark.getText();
// Set the name and text of the bookmark.
bookmark.setName("RenamedBookmark");
bookmark.setText("This is a new bookmarked text.");
remove | |
public void remove()
throws java.lang.Exception |
-
Removes the bookmark from the document. Does not remove text inside the bookmark.
Example:
Shows how to remove a particular bookmark from a document.
Document doc = new Document(getMyDir() + "Bookmark.doc");
// Use the indexer of the Bookmarks collection to obtain the desired bookmark.
Bookmark bookmark = doc.getRange().getBookmarks().get("MyBookmark");
// Remove the bookmark. The bookmarked text is not deleted.
bookmark.remove();
See Also:
Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
Aspose.Words Support Forum - our preferred method of support.