Skip to main content

GetRange

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

The paragraph must be attached to the document before calling this method.

Syntax​

expression.GetRange(Start, End);

expression - A variable that represents an ApiParagraph class.

Parameters​

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

Returns​

ApiRange | null

Example​

Select a range of characters within a paragraph in a document.

// How do I get a specific character range from a paragraph in a document?

// Bold a chosen slice of text by extracting it as a range from a paragraph in a document.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
paragraph.AddText("This is just a sample paragraph.");
let range = paragraph.GetRange(8, 11);
range.SetBold(true);