Skip to main content

GetRange

Returns a Range object that represents the document part contained in the specified hyperlink.

Syntax​

expression.GetRange(Start, End);

expression - A variable that represents an ApiHyperlink class.

Parameters​

NameRequired/OptionalData typeDefaultDescription
StartRequiredNumberStart position index in the current element.
EndRequiredNumberEnd position index in the current element.

Returns​

ApiRange

Example​

Obtain a text range that spans part of a hyperlink in a document.

// How do I select a portion of a hyperlink as a range in a document?

// Apply bold formatting to a subset of hyperlink characters using a range 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 range = hyperlink.GetRange(0, 2);
range.SetBold(true);