Skip to main content

GetElement

Returns the hyperlink element using the position specified.

Syntax

expression.GetElement(nPos);

expression - A variable that represents a ApiHyperlink class.

Parameters

NameRequired/OptionalData typeDefaultDescription
nPosRequirednumberThe position where the element which content we want to get must be located.

Returns

ParagraphContent

Example

Get the hyperlink element using the position specified in a document.

// How to get the element of the hyperlink knowing its index in a document.

// Add a hyperlink to the paragraph and get its element in a document.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
let run1 = Api.CreateRun();
run1.AddText("Api Document Builder.");
paragraph.AddElement(run1, 0);
let run2 = Api.CreateRun();
run2.AddText(" ONLYOFFICE for developers");
paragraph.AddElement(run2, 1);
let hyperlink = paragraph.AddHyperlink("https://api.onlyoffice.com/docbuilder/basic");
let element = hyperlink.GetElement(1);
paragraph = Api.CreateParagraph();
paragraph.AddElement(element);
doc.Push(paragraph);