跳到主要内容

HexColor

从十六进制字符串创建颜色。

语法

expression.HexColor(hexString);

expression - 表示 Api 类的变量。

参数

名称必需/可选数据类型默认值描述
hexString必需string表示颜色的十六进制字符串。

返回值

ApiColor

示例

将十六进制代码定义的自定义颜色应用于文档中的文本。

// How do I set a font color using a hex value in a document?

// Color paragraph text with a specific hex color in a document.

const doc = Api.GetDocument();
const color = Api.HexColor('#DECADE');
const paragraph = doc.GetElement(0);
paragraph.AddText('This text is in hex color.');
paragraph.SetColor(color);