跳到主要内容

SetHighlight

指定应用于当前段落内容背景的高亮颜色。

语法

expression.SetHighlight(sColor);

expression - 表示 ApiParagraph 类的变量。

参数

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

返回值

ApiParagraph

示例

此示例为段落设置「浅灰色」高亮颜色。

// How to create a paragraph and highlight it with color.

// Set a light gray highlight color to a paragraph and insert it to the slide shape.

const presentation = Api.GetPresentation();
const slide = presentation.GetSlideByIndex(0);
slide.RemoveAllObjects();

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", 300 * 36000, 130 * 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);
slide.AddObject(shape);