Skip to main content

SetImage

Sets image to button widget field.

Syntax

expression.SetImage(imageUrl, appearance);

expression - A variable that represents a ApiButtonWidget class.

Parameters

NameRequired/OptionalData typeDefaultDescription
imageUrlOptionalstring""The image URL.
appearanceOptionalButtonAppearance"normal"The appearance state.

Returns

boolean

Example

Set image for button widget in a PDF document.

// Assign an image resource to an image field with normal state.

// Add the image field to a PDF page.

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

let widgets = imageField.GetAllWidgets();
widgets[0].SetImage('https://static.onlyoffice.com/assets/docs/samples/img/onlyoffice_logo.png', 'normal');