跳到主要内容

GetLinkedText

Returns the hyperlink address.

Syntax

expression.GetLinkedText();

expression - A variable that represents a ApiHyperlink class.

Parameters

This method doesn't have any parameters.

Returns

string

Example

This example returns the hyperlink address.

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

const fill = Api.CreateSolidFill(Api.RGB(210, 180, 222));
const stroke = Api.CreateStroke(0, Api.CreateNoFill());
const shape = Api.CreateShape('rect', Api.MillimetersToEmus(300), Api.MillimetersToEmus(130), fill, stroke);
shape.SetPosition(Api.MillimetersToEmus(20), Api.MillimetersToEmus(35));

const docContent = shape.GetContent();
const paragraph = docContent.GetElement(0);
const run = Api.CreateRun();
run.AddText('ONLYOFFICE Document Builder');
paragraph.AddElement(run);

const infoParagraph = Api.CreateParagraph();
let hyperlink;

hyperlink = paragraph.AddHyperlink('https://api.onlyoffice.com/docbuilder/basic');
infoParagraph.AddText('Text hyperlink linked text: ' + hyperlink.GetLinkedText());
infoParagraph.AddLineBreak();

shape.SetHyperlink(Api.CreateHyperlink('https://api.onlyoffice.com/'));
hyperlink = shape.GetHyperlink();
infoParagraph.AddText('Shape hyperlink linked text: ' + hyperlink.GetLinkedText());

docContent.Push(infoParagraph);
slide.AddObject(shape);