Skip to main content

SetTextRect

Sets the text rectangle for the current geometry.

Syntax

expression.SetTextRect(sLeft, sTop, sRight, sBottom);

expression - A variable that represents a ApiGeometry class.

Parameters

NameRequired/OptionalData typeDefaultDescription
sLeftRequiredstringThe left guide name or value.
sTopRequiredstringThe top guide name or value.
sRightRequiredstringThe right guide name or value.
sBottomRequiredstringThe bottom guide name or value.

Returns

boolean

Example

Define the text bounding rectangle for a custom geometry shape in a document.

// How do I set the area where text appears inside a custom shape in a document?

// Constrain text to a specific region within a non-rectangular custom shape in a document.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
let customGeometry = Api.CreateCustomGeometry();
customGeometry.AddAdj("adj1", 25000);
customGeometry.SetAdjValue("adj1", 30000);
paragraph.AddText("Adjustment value: " + customGeometry.GetAdjValue("adj1"));
customGeometry.AddGuide("x1", "*/", "adj1", "w", "100000");
customGeometry.SetTextRect("x1", "0", "w", "h");
customGeometry.AddConnectionPoint("0", "hc", "0");
let path = customGeometry.AddPath();
path.SetStroke(true);
path.SetFill("norm");
path.MoveTo("l", "t");
path.LineTo("r", "t");
path.LineTo("r", "b");
path.LineTo("l", "b");
path.LineTo("x1", "hd2");
path.Close();
let fill = Api.CreateSolidFill(Api.RGB(255, 200, 100));
let stroke = Api.CreateStroke(36000, Api.CreateSolidFill(Api.RGB(200, 100, 0)));
let shape = Api.CreateShape("rect", 100 * 36000, 100 * 36000, fill, stroke);
shape.SetGeometry(customGeometry);
paragraph.AddDrawing(shape);