Skip to main content

CreateImage

Creates an image with the parameters specified.

Syntax​

expression.CreateImage(imageSrc, width, height);

expression - A variable that represents a Api class.

Parameters​

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

Returns​

ApiImage

Example​

Create an image object using an url and specifying its width and height in a PDF document.

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

// Create the image in a PDF document.

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