Skip to main content

ReplaceCurrentImage

Replaces the current image with an image specified.

Syntax

expression.ReplaceCurrentImage(sImageUrl, Width, Height);

expression - A variable that represents a ApiDocument class.

Parameters

NameRequired/OptionalData typeDefaultDescription
sImageUrlRequiredstringThe 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

boolean

Example

This example replaces the current image with an image specified.

// How to change the image to another one.

// Add the new image instead of another using the URL.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
let drawing = Api.CreateImage("https://static.onlyoffice.com/assets/docs/samples/img/onlyoffice_logo.png", 60 * 36000, 35 * 36000);
paragraph.AddDrawing(drawing);
drawing.Select();
doc.ReplaceCurrentImage("https://helpcenter.onlyoffice.com/images/Help/GettingStarted/Documents/big/EditDocument.png", 60 * 36000, 35 * 36000);