跳到主要内容

SetValue

为所有按钮字段控件设置图像

备注

不适用于 "textOnly" 布局。

语法​

expression.SetValue(imageUrl);

expression - 表示 ApiButtonField 类的变量。

参数​

名称必需/可选数据类型默认值描述
imageUrl可选string""要为按钮设置的图像 URL(目前仅支持互联网 URL 或 Base64 编码的图像)

返回值​

boolean

示例​

在 PDF 中为所有按钮字段控件设置图像值。

// Useful for assigning an image to a button field.

// Create an image field and set the image for its widgets.

let doc = Api.GetDocument();
let page = doc.GetPage(0);
let buttonField = Api.CreateImageField([10, 10, 100, 100]);
page.AddObject(buttonField);

buttonField.SetValue("https://static.onlyoffice.com/assets/docs/samples/img/onlyoffice_logo.png");