Click or drag to resize
BookmarkStart Class
Represents the start of a bookmark.
Inheritance Hierarchy

Namespace: GemBox.Document
Assembly: GemBox.Document (in GemBox.Document.dll) Version: 25.3.30.1213
Syntax
public sealed class BookmarkStart : Inline

The BookmarkStart type exposes the following members.

Constructors
  NameDescription
Public methodBookmarkStart
Initializes a new instance of the BookmarkStart class.
Top
Methods
Properties
  NameDescription
Public propertyContent
Gets the content of the current Element.
(Inherited from Element.)
Public propertyDocument
Gets the owner document.
(Inherited from Element.)
Public propertyElementType
Gets the ElementType of this Element instance.
(Overrides ElementElementType.)
Public propertyName
Gets the name of this bookmark.
Public propertyParent
Gets the parent of this Element instance.
(Inherited from Element.)
Public propertyParentCollection
Gets the InlineCollection that contains this Inline instance.
(Inherited from Inline.)
Top
Remarks

BookmarkStart element is used in a pair with BookmarkEnd element to bookmark a specific part of the document with a specific name.

For BookmarkStart and BookmarkEnd to be considered as a pair, their names must match.

BookmarkStart is an inline element. For more information about GemBox.Document document content model, see Content Model.

To easily navigate and manipulate over all bookmarks in the document, GemBox.Document also contains a Bookmark class that serves as a façade for BookmarkStart and BookmarkEnd elements. Bookmark objects can be retrieved from DocumentModel.Bookmarks collection.

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 and Modify Bookmarks samples.

Examples

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);
See Also