跳到主要内容

AddElement

Adds a paragraph or a table or a block content control to the current container.

Syntax

expression.AddElement(element, pos);

expression - A variable that represents a ApiBlockLvlSdt class.

Parameters

NameRequired/OptionalData typeDefaultDescription
elementRequiredDocumentElementThe type of the element which will be added to the current container.
posRequiredNumberThe specified position.

Returns

boolean

Example

This example adds a paragraph to the container.

let doc = Api.GetDocument();
let blockLvlSdt = Api.CreateBlockLvlSdt();
let paragraph = Api.CreateParagraph();
paragraph.AddText("This is a block text content control.");
blockLvlSdt.AddElement(paragraph, 0);
doc.AddElement(0, blockLvlSdt);