跳到主要内容

GetBookmarkRange

返回书签范围。

语法

expression.GetBookmarkRange(sName);

expression - 表示 ApiDocument 类的变量。

参数

名称必需/可选数据类型默认值描述
sName必需string书签名称。

返回值

ApiRange | null

示例

检索文档中命名书签覆盖的文本范围。

// How do I get the range that a bookmark spans in a document?

// Apply bold formatting to a bookmarked range by looking it up by name in a document.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
paragraph.AddText("ONLYOFFICE Document Builder");
let range = doc.GetRange(0, 9);
range.AddBookmark("Bookmark");
range = doc.GetBookmarkRange("Bookmark");
range.SetBold(true);