DocumentBuilderStartBookmark Method

Marks the current position in the document as a bookmark start.

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.7.0

Syntax

public BookmarkStart StartBookmark(
	string bookmarkName
)

Parameters

bookmarkName
Type: SystemString
Name of the bookmark.

Return Value

Type: BookmarkStart
The bookmark start node that was just created.

Remarks

Bookmarks in a document can overlap and span any range. To create a valid bookmark you need to call both StartBookmark(String) and EndBookmark(String) with the same bookmarkName parameter.

Badly formed bookmarks or bookmarks with duplicate names will be ignored when the document is saved.

Examples

Shows how to add some text into the document and encloses the text in a bookmark using DocumentBuilder.
DocumentBuilder builder = new DocumentBuilder();

builder.StartBookmark("MyBookmark");
builder.Writeln("Text inside a bookmark.");
builder.EndBookmark("MyBookmark");
Shows how to insert a hyperlink referencing a local bookmark.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.StartBookmark("Bookmark1");
builder.Write("Bookmarked text.");
builder.EndBookmark("Bookmark1");

builder.Writeln("Some other text");

// Specify font formatting for the hyperlink
builder.Font.Color = Color.Blue;
builder.Font.Underline = Underline.Single;

// Insert hyperlink
// Switch \o is used to provide hyperlink tip text
builder.InsertHyperlink("Hyperlink Text", @"Bookmark1"" \o ""Hyperlink Tip", true);

// Clear hyperlink formatting
builder.Font.ClearFormatting();

doc.Save(ArtifactsDir + "DocumentBuilder.InsertHyperlinkToLocalBookmark.docx");

See Also