ReplaceCurrentImage

function ReplaceCurrentImage(sImageUrl: string = null, Width: EMU = null, Height: EMU = null): void

Description

Replaces the current image with an image specified.

Parameters

sImageUrlstringdefault: null

The image source where the image to be inserted should be taken from (currently, only internet URL or Base64 encoded images are supported).

WidthEMUdefault: null

The image width in English measure units.

HeightEMUdefault: null

The image height in English measure units.

Returns

void

Try It

var oDocument = Api.GetDocument();
var oParagraph = oDocument.GetElement(0);
var oDrawing = Api.CreateImage("https://api.onlyoffice.com/content/img/docbuilder/examples/coordinate_aspects.png", 60 * 36000, 35 * 36000);
oParagraph.AddDrawing(oDrawing);
oDrawing.Select();
oDocument.ReplaceCurrentImage("https://helpcenter.onlyoffice.com/images/Help/GettingStarted/Documents/big/EditDocument.png", 60 * 36000, 35 * 36000);

Get Help

  • If you have any questions about ONLYOFFICE Docs, try the FAQ section first.
  • You can request a feature or report a bug by posting an issue on GitHub.
  • You can also ask our developers on ONLYOFFICE forum (registration required).