TRY NEW VERSION

Try now New API BETA

Try out the new view and capabilities of the API documentation

START

SetImage

SetImage(sImageSrc, nWidth, nHeight) → { 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).

nWidth EMU

The image width in English measure units.

nHeight EMU

The image height in English measure units.

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", 60 * 36000, 35 * 36000);
var oParagraph = oDocument.GetElement(0);
oParagraph.AddElement(oPictureForm);
builder.SaveFile("docx", "SetImage.docx");
builder.CloseFile();

Resulting document