跳到主要内容

InsertContent

将元素数组插入到文档的当前位置。

语法

expression.InsertContent(arrContent, isInline, oPr);

expression - 表示 ApiDocument 类的变量。

参数

名称必需/可选数据类型默认值描述
arrContent必需DocumentElement[]要插入的元素数组。
isInline可选booleanfalse是否行内插入(仅对第一个和最后一个元素有效,且仅当它是段落时)。
oPr可选object指定为插入的元素保留文本和段落文档属性。对象应如下所示:{"KeepTextOnly": true}。

返回值

boolean

示例

此示例将元素数组插入到文档的当前位置。

// How to insert the paragraph to the document.

// Create a paragraph and show it.

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]);