SetColor
设置当前段落的文本颜色。
语法
expression.SetColor(color);
expression - 表示 ApiParagraph 类的变量。
参数
| 名称 | 必需/可选 | 数据类型 | 默认值 | 描述 |
|---|---|---|---|---|
| color | 必需 | ApiColor | 文本颜色。 |
返回值
示例
此示例为当前段落设置文本颜色。
// Color the paragraph text with orange.
// Get the first paragraph and make its font color orange.
const doc = Api.GetDocument();
const firstParagraph = doc.GetElement(0);
firstParagraph.AddText('This is a paragraph with the font color set to orange.');
firstParagraph.SetColor(Api.HexColor('#FF6F3D'));
const color = Api.HexColor('ff6f3d');
const secondParagraph = Api.CreateParagraph();
secondParagraph.AddText('This text is in same orange color, but created using HexColor method.');
secondParagraph.SetColor(color);
doc.Push(secondParagraph);