Skip to main content

GetLinkedText

Returns the hyperlink address.

Syntax​

expression.GetLinkedText();

expression - A variable that represents an ApiHyperlink class.

Parameters​

This method doesn't have any parameters.

Returns​

string

Example​

Get the hyperlink address in a presentation.

// How do I retrieve the linked text or URL from a hyperlink in a presentation?

// Obtain the linked text from a hyperlink in a presentation.

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('Visit ONLYOFFICE for developers');
paragraph.AddElement(run);

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

hyperlink = paragraph.AddHyperlink('https://api.onlyoffice.com');
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);