跳到主要内容

SetHighlight

指定添加到文本属性并作为背景应用于当前运行/范围/段落内容的高亮颜色。

语法

expression.SetHighlight(sColor);

expression - 表示 ApiTextPr 类的变量。

参数

名称必需/可选数据类型默认值描述
sColor必需highlightColor可用的突出显示颜色。

返回值

ApiTextPr

示例

此示例指定添加到文本属性并作为背景应用于当前运行/范围/段落内容的高亮颜色。

// How to color a text object background.

// Create a text run object, add color to its background.

let doc = Api.GetDocument();
let textPr = doc.GetDefaultTextPr();
textPr.SetHighlight("lightGray");
let paragraph = doc.GetElement(0);
paragraph.AddText("A sample text highlighted with light gray color using the text properties.");