SetImage

function SetImage(sImageSrc: string = null, nWidth: EMU = null, nHeight: EMU = null): boolean

Description

Sets an image to the current picture form.

Parameters

sImageSrcstringdefault: null

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

nWidthEMUdefault: null

The image width in English measure units.

nHeightEMUdefault: null

The image height in English measure units.

Returns

boolean

Try It

var oDocument = Api.GetDocument();
var oPictureForm = Api.CreatePictureForm({"tip": "Upload your photo", "required": true, "placeholder": "Photo", "scaleFlag": "tooBig", "lockAspectRatio": true, "respectBorders": false, "shiftX": 50, "shiftY": 50});
oPictureForm.SetImage("https://api.onlyoffice.com/content/img/docbuilder/examples/user-profile.png");
var oParagraph = oDocument.GetElement(0);
oParagraph.AddElement(oPictureForm);

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).