跳到主要内容

CreateHyperlink

创建要插入到当前段落或表格中的新超链接文本块。

语法

expression.CreateHyperlink(link, display, screenTipText);

expression - 表示 Api 类的变量。

参数

名称必需/可选数据类型默认值描述
link必需string超链接地址。
display必需string用于显示超链接的文本。
screenTipText必需string屏幕提示文本。

返回值

ApiHyperlink

示例

此示例创建一个超链接并将其粘贴到文档中。

// How to create the ApiHyperlink object and add it to the ApiParagraph class.

// Creates a hyperlink with the specified URL address, display text and tip text and adds it to the first paragraph of the document.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
let hyperlink = Api.CreateHyperlink("https://api.onlyoffice.com/", "ONLYOFFICE Document Builder", "ONLYOFFICE for developers");
paragraph.AddElement(hyperlink, 0);
paragraph.AddLineBreak();
paragraph.AddText("Class type of the created object: " + hyperlink.GetClassType());