跳到主要内容

InsertParagraph

Inserts a paragraph at the specified position.

Syntax

expression.InsertParagraph(paragraph, sPosition, beRNewPara);

expression - A variable that represents a ApiDrawing class.

Parameters

NameRequired/OptionalData typeDefaultDescription
paragraphRequiredstringApiParagraph
sPositionRequiredstringThe position where the text or paragraph will be inserted ("before" or "after" the drawing specified).
beRNewParaRequiredbooleanDefines if this method returns a new paragraph (true) or the current ApiDrawing (false).

Returns

ApiParagraph | ApiDrawing

Example

This example inserts a paragraph at the specified position.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
paragraph.AddText("This graphic object with paragraph.");
let fill = Api.CreateSolidFill(Api.CreateRGBColor(255, 111, 61));
let stroke = Api.CreateStroke(0, Api.CreateNoFill());
let drawing = Api.CreateShape("rect", 3212465, 963295, fill, stroke);
paragraph.AddDrawing(drawing);
paragraph = Api.CreateParagraph();
paragraph.AddText("This is a new paragraph.");
drawing.InsertParagraph(paragraph);