跳到主要内容

CreateHyperlink

创建新的超链接对象,用于在绘图对象(形状或图像)上设置超链接。

语法

expression.CreateHyperlink(link, tooltip);

expression - 表示 Api 类的变量。

参数

名称必需/可选数据类型默认值描述
link必需string超链接地址。
tooltip必需string工具提示文本。

返回值

ApiHyperlink

示例

此示例展示如何创建超链接并将其设置到图像。

const presentation = Api.GetPresentation();
const slide = presentation.GetSlideByIndex(0);
slide.RemoveAllObjects();

const image = Api.CreateImage(
'https://static.onlyoffice.com/assets/docs/samples/img/onlyoffice_logo.png',
150 * 36000, 150 * 36000
);
slide.AddObject(image);

const hyperlink = Api.CreateHyperlink('https://onlyoffice.com', 'Link to OnlyOffice website');
image.SetHyperlink(hyperlink);