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

This example creates an image and pastes it into the document.

// Creates the ApiImage object and adds it to the ApiParagraph class.

// How to create the ApiImage object using the URL to the image, its width and height.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
let image = Api.CreateImage("https://static.onlyoffice.com/assets/docs/samples/img/onlyoffice_logo.png", 60 * 36000, 35 * 36000);
paragraph.AddDrawing(image);