跳到主要内容

GetRange

返回表示指定内容控件中包含的文档部分的 Range 对象。

语法

expression.GetRange(start, end);

expression - 表示 ApiBlockLvlSdt 类的变量。

参数

名称必需/可选数据类型默认值描述
start必需Number当前元素中的起始位置索引。
end必需Number当前元素中的结束位置索引。

返回值

ApiRange

示例

获取表示文档中指定内容控件所包含的文档部分的 Range 对象。

// Create a block content control, add a text to it, and return a range between positions 10 and 16 of the element in a document.

// Return the range object from the container and set a bold property to it in a document.

let doc = Api.GetDocument();
let blockLvlSdt = Api.CreateBlockLvlSdt();
blockLvlSdt.GetContent().GetElement(0).AddText("This is a block text content control.");
doc.AddElement(0, blockLvlSdt);
let range = blockLvlSdt.GetRange(10, 16);
range.SetBold(true);