跳到主要内容

CreateImageField

Creates a image field.

Syntax

expression.CreateImageField(aRect);

expression - A variable that represents a Api class.

Parameters

NameRequired/OptionalData typeDefaultDescription
aRectRequiredRectwidget rect

Returns

ApiButtonField

Example

How to create and add a field with image to document.

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');