Skip to main content

SetPicture

Sets the content (image) for the picture content control.

The URL should be an internet link to the image.

Syntax​

expression.SetPicture(imageUrl);

expression - A variable that represents an ApiInlineLvlSdt class.

Parameters​

NameRequired/OptionalData typeDefaultDescription
imageUrlRequiredstringThe URL of the image to be used for the content control. Currently, only internet URLs are supported.

Returns​

boolean

Example​

Insert an image into a picture content control in a document.

// How do I load an image from a URL into a picture content control in a document?

// Replace the default placeholder of a picture control with an actual image in a document.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
let contentControl = doc.AddPictureContentControl();
contentControl.SetPicture('https://static.onlyoffice.com/assets/docs/samples/img/presentation_sky.png');