Get Started
Usage API
More information

AddElement

AddElement(oElement, nPos) → { bool }

Add a paragraph or a table or a blocklvl content control to the document.

Parameters:

Name Type Description
oElement DocumentElement

The type of the element which will be added to the document.

nPos Number

The specified position.

Returns:

Type
bool

Example

Copy code
builder.CreateFile("docx");
oDocument = Api.GetDocument();
oBlockLvlSdt = Api.CreateBlockLvlSdt();
oParagraph = Api.CreateParagraph();
oParagraph.AddText("This is a block text content control.");
oBlockLvlSdt.AddElement(oParagraph, 0);
oDocument.AddElement(0, oBlockLvlSdt);
builder.SaveFile("docx", "AddElement.docx");
builder.CloseFile();

Resulting document