HexColor
从十六进制字符串创建颜色。
语法
expression.HexColor(hexString);
expression - 表示 Api 类的变量。
参数
| 名称 | 必需/可选 | 数据类型 | 默认值 | 描述 |
|---|---|---|---|---|
| hexString | 必需 | string | 表示颜色的十六进制字符串。 |
返回值
示例
将十六进制代码定义的自定义颜色应用于文档中的文本。
// 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);