跳到主要内容

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 creastes an image and pastes it into the 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, 35 * 36000);
paragraph.AddDrawing(image);