Get Started
Documentation

AddElement

AddElement(oElement, [nPos]) → { boolean }

Add an element to the inline text content control.

Parameters:

Name Type Default Description
oElement ParagraphContent

The document element which will be added at the position specified. Returns false if the type of oElement is not supported by an inline text content control.

nPos number null

The position of the element where it will be added to the current inline text content control. If this value is not specified then the element will be added to the end of the current inline text content control.

Returns:

Type
boolean

Example

Copy code
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oParagraph, oRun;
oParagraph = oDocument.GetElement(0);
oInlineLvlSdt = Api.CreateInlineLvlSdt();
oParagraph.AddInlineLvlSdt(oInlineLvlSdt);
oRun = Api.CreateRun();
oRun.AddText("This is an inline text content control with a text run in it.");
oInlineLvlSdt.AddElement(oRun, 0);
builder.SaveFile("docx", "AddElement.docx");
builder.CloseFile();

Resulting document