SetHighlight
指定添加到文本属性并作为背景应用于当前运行/范围/段落内容的高亮颜色。
语法
expression.SetHighlight(sColor);
expression - 表示 ApiTextPr 类的变量。
参数
| 名称 | 必需/可选 | 数据类型 | 默认值 | 描述 |
|---|---|---|---|---|
| sColor | 必需 | highlightColor | 可用的突出显示颜色。 |
返回值
示例
此示例指定添加到文本属性并作为背景应用于当前运行/范围/段落内容的高亮颜色。
// 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.");