跳到主要内容

InsertContent

Inserts an array of elements into the current position of the document.

Syntax

expression.InsertContent(arrContent, isInline, oPr);

expression - A variable that represents a ApiDocument class.

Parameters

NameRequired/OptionalData typeDefaultDescription
arrContentRequiredDocumentElement[]An array of elements to insert.
isInlineOptionalbooleanfalseInline insert or not (works only for the last and the first element and only if it's a paragraph).
oPrOptionalobjectSpecifies that text and paragraph document properties are preserved for the inserted elements. The object should look like this: {"KeepTextOnly": true}.

Returns

boolean

Example

This example inserts an array of elements into the current position of the document.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
paragraph = Api.CreateParagraph();
paragraph.AddText("This is a sample text. It was inserted here.");
doc.InsertContent([paragraph]);