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​

Insert an image from a URL into a paragraph in a document.

// How do I add an image with a specific width and height to a document?

// Place a remotely hosted picture at a fixed size inside a paragraph in a document.

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, 60 * 36000
);
paragraph.AddDrawing(image);