SetHighlight
指定应用于当前段落内容背景的高亮颜色。
语法
expression.SetHighlight(sColor);
expression - 表示 ApiParagraph 类的变量。
参数
| 名称 | 必需/可选 | 数据类型 | 默认值 | 描述 |
|---|---|---|---|---|
| sColor | 必需 | highlightColor | 可用的突出显示颜色。 |
返回值
示例
此示例为段落设置「浅灰色」高亮颜色。
// How to create a paragraph and highlight it with color.
// Set a light gray highlight color to a paragraph and insert it to the page shape.
const doc = Api.GetDocument();
const page = doc.GetPage(0);
const gs1 = Api.CreateGradientStop(Api.RGB(255, 213, 191), 0);
const gs2 = Api.CreateGradientStop(Api.RGB(255, 111, 61), 100000);
const fill = Api.CreateRadialGradientFill([gs1, gs2]);
const stroke = Api.CreateStroke(0, Api.CreateNoFill());
const shape = Api.CreateShape("flowChartMagneticTape", 150 * 36000, 65 * 36000, fill, stroke);
shape.SetPosition(608400, 1267200);
const docContent = shape.GetDocContent();
const paragraph = docContent.GetElement(0);
paragraph.AddText("This is just a sample text. ");
paragraph.SetHighlight("lightGray");
docContent.Push(paragraph);
page.AddObject(shape);