跳到主要内容

CreateHyperlink

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

语法

expression.CreateHyperlink(link, display, screenTipText);

expression - 表示 Api 类的变量。

参数

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

返回值

ApiHyperlink

示例

在文档中插入带有自定义显示文本的可点击超链接。

// How do I add a hyperlink with a tooltip to a paragraph in a document?

// Embed a named web link that shows a tooltip when hovered, then read back its type in a 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());