InsertContent

InsertContent(arrContent, [isInline], [oPr]) → { boolean }

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

Parameters:

Name Type Default Description
arrContent Array.<DocumentElement>

An array of elements to insert.

isInline boolean false

Inline insert or not (works only for the last and the first element and only if it's a paragraph).

oPr object null

Specifies that text and paragraph document properties are preserved for the inserted elements. The object should look like this: {"KeepTextOnly": true}.

Returns:

Type
boolean

Example

Copy code
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oParagraph = oDocument.GetElement(0);
oParagraph = Api.CreateParagraph();
oParagraph.AddText("This is a sample text. It was inserted here.");
oDocument.InsertContent([oParagraph]);
builder.SaveFile("docx", "InsertContent.docx");
builder.CloseFile();

Resulting document