跳到主要内容

CreateImage

Creates an image with the parameters specified.

Syntax

expression.CreateImage(sImageSrc, nWidth, nHeight);

expression - A variable that represents a Api class.

Parameters

NameRequired/OptionalData typeDefaultDescription
sImageSrcRequiredstringThe image source where the image to be inserted should be taken from (currently, only internet URL or Base64 encoded images are supported).
nWidthRequiredEMUThe image width in English measure units.
nHeightRequiredEMUThe image height in English measure units.

Returns

ApiImage

Example

How to create an image object using a url and specifying its width and height.

// Create an image and insert it to the page.

const doc = Api.GetDocument();
const page = doc.GetPage(0);
const shape = Api.CreateImage(
'https://static.onlyoffice.com/assets/docs/samples/img/onlyoffice_logo.png',
60 * 36000, 60 * 36000
);
page.AddObject(shape);