Skip to main content

GetDisplayedText

Returns the hyperlink display text.

Syntax​

expression.GetDisplayedText();

expression - A variable that represents an ApiHyperlink class.

Parameters​

This method doesn't have any parameters.

Returns​

string

Example​

Read the visible label of a hyperlink in a document.

// How do I get the text that is shown for a hyperlink in a document?

// Confirm what words a reader sees when a hyperlink is rendered in a document.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
paragraph.AddText("Visit ONLYOFFICE for developers");
let hyperlink = paragraph.AddHyperlink("https://api.onlyoffice.com");
let displayedText = hyperlink.GetDisplayedText();
paragraph = Api.CreateParagraph();
paragraph.AddText("Displayed text: " + displayedText);
doc.Push(paragraph);