Get Started
Usage API

GetElementsCount

GetElementsCount() → { number }

Get the number of elements in the current hyperlink.

Parameters:

This method doesn't have any parameters.

Returns:

Type
number

Example

Copy code
builder.CreateFile("docx");
oDocument = Api.GetDocument();
oParagraph = oDocument.GetElement(0);
oRun1 = Api.CreateRun();
oRun1.AddText("Api Document Builder.");
oParagraph.AddElement(oRun1, 0);
oRun2 = Api.CreateRun();
oRun2.AddText(" ONLYOFFICE for developers");
oParagraph.AddElement(oRun2, 1);
oHyperlink = oParagraph.AddHyperlink("http://api.teamlab.info/docbuilder/basic");
oElementsCount = oHyperlink.GetElementsCount();
oParagraph = Api.CreateParagraph();
oParagraph.AddText("Number of elements in hyperlink: " + oElementsCount + "
Elements: oParagraph, oRun1, oRun2, oHyperlink");
oDocument.Push(oParagraph);
builder.SaveFile("docx", "GetElementsCount.docx");
builder.CloseFile();

Resulting document