SetImage

SetImage(sImageSrc) → { boolean }

Sets an image to the current picture form.

Parameters:

Name Type Description
sImageSrc string

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

Returns:

Type
boolean

Example

Copy code
builder.CreateFile("docx");
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);
builder.SaveFile("docx", "SetImage.docx");
builder.CloseFile();

Resulting document