跳到主要内容

SetTextColor

设置控件文本颜色。

语法

expression.SetTextColor(color);

expression - 表示 ApiBaseWidget 类的变量。

参数

名称必需/可选数据类型默认值描述
color必需ApiColor文本颜色。

返回值

boolean

示例

在 PDF 中为所有字段控件应用文本颜色。

// How do I set the text color for widgets in a PDF?

// Change the text display color for widget content in a PDF.

let doc = Api.GetDocument();
let page = doc.GetPage(0);
let textField = Api.CreateTextField([10, 10, 160, 30]);
page.AddObject(textField);

textField.SetValue('Example text');
textField.AddWidget(0, [10, 40, 160, 60]);
let widgets = textField.GetAllWidgets();
let rgbColor = Api.RGB(255, 100, 0);
widgets.forEach(function(widget) {
widget.SetTextColor(rgbColor);
});