InsertParagraph

function InsertParagraph(
  paragraph: string | ApiParagraph = null,
  sPosition: string = null,
  beRNewPara: boolean = null,
): ApiParagraph | "null"

Description

Inserts a paragraph at the specified position.

Parameters

paragraphstring | ApiParagraphdefault: null

Text or paragraph.

sPositionstringdefault: null

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

beRNewParabooleandefault: null

Defines if this method returns a new paragraph (true) or the current paragraph (false).

Returns

ApiParagraph | "null"

Try It

var oDocument = Api.GetDocument();
var oParagraph1 = oDocument.GetElement(0);
oParagraph1.AddText("This is just a sample text.");
var oParagraph2 = Api.CreateParagraph();
oParagraph2.AddText("This paragraph was inserted here.");
oParagraph1.InsertParagraph(oParagraph2, "after", true);

Get Help

  • If you have any questions about ONLYOFFICE Docs, try the FAQ section first.
  • You can request a feature or report a bug by posting an issue on GitHub.
  • You can also ask our developers on ONLYOFFICE forum (registration required).