Get Started
Usage API
More information

InsertParagraph

InsertParagraph(paragraph, sPosition, beRNewPara) → { ApiParagraph | null }

Insert a paragraph at the specified position.

Parameters:

Name Type Description
paragraph string | ApiParagraph

Text or paragraph.

sPosition string

The position where the text or paragraph will be inserted ("before" or "after" the paragraph specified).

beRNewPara bool

If "true" -> returns new paragraph, else returns this paragraph.

Returns:

Type
ApiParagraph | null

Example

Copy code
builder.CreateFile("docx");
oDocument = Api.GetDocument();
oParagraph1 = oDocument.GetElement(0);
oParagraph1.AddText("This is just a sample text.");
oParagraph2 = Api.CreateParagraph();
oParagraph2.AddText("This paragraph was inserted here.");
oParagraph1.InsertParagraph(oParagraph2, "after", true);
builder.SaveFile("docx", "InsertParagraph.docx");
builder.CloseFile();

Resulting document