BookmarkCollection Class |
Namespace: GemBox.Document
The BookmarkCollection type exposes the following members.
Name | Description | |
---|---|---|
![]() | Count |
Gets the number of Bookmarks contained in the BookmarkCollection.
|
![]() | ItemInt32 |
Gets the Bookmark at the specified index.
|
![]() | ItemString |
Gets the Bookmark with the specified name.
|
Name | Description | |
---|---|---|
![]() | Clear | Removes all items from the ICollectionT. |
![]() | Contains | Determines whether the ICollectionT contains a specific value. |
![]() | CopyTo | |
![]() | GetEnumerator | Returns an enumerator that iterates through the collection. |
![]() | IndexOf | Determines the index of a specific item in the IListT. |
![]() | Remove | Removes the first occurrence of a specific object from the ICollectionT. |
![]() | RemoveAt | Removes the IListT item at the specified index. |
BookmarkCollection is used in a DocumentModel.Bookmarks property.
DocumentModel.Bookmarks collection contains all bookmarks in the document. Use DocumentModel.Bookmarks collection to retrieve a Bookmark with a specified name, iterate over all bookmarks or remove a bookmark.
Bookmarks are usually used in a conjunction with Hyperlinks or Fields for navigating to a bookmarked part of the document or to render a page number (or some other information) of a bookmarked part of the document. For more information, see Bookmarks and Hyperlinks example.
Following example shows how to insert a bookmarked content to a document, and later retrieve and delete it through DocumentModel.Bookmarks collection.
// Create a new empty document. var doc = new DocumentModel(); // Insert a bookmarked text. doc.Sections.Add( new Section(doc, new Paragraph(doc, new BookmarkStart(doc, "MyBookmark"), new Run(doc, "My bookmarked text"), new BookmarkEnd(doc, "MyBookmark")))); // Retrieve a bookmark. var myBookmark = doc.Bookmarks["MyBookmark"]; // Delete a bookmark. Deletes BookmarkStart and BookmarkEnd elements. Content that was bookmarked will not be deleted! doc.Bookmarks.Remove(myBookmark);