跳到主要内容

SetPicture

设置图片内容控件的内容(图像)。

URL 应为指向图像的互联网链接。

语法​

expression.SetPicture(imageUrl);

expression - 表示 ApiInlineLvlSdt 类的变量。

参数​

名称必需/可选数据类型默认值描述
imageUrl必需string用于内容控件的图像 URL。目前仅支持互联网 URL。

返回值​

boolean

示例​

在文档中将图像插入图片内容控件。

// 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');