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

Create adjustable geometry with guides and connection points for a presentation. Displays adjustment value and apply custom geometry to shape.

// How to set text rect for a geometry in a presentation?

// Set text rect and display the result in a presentation.

let presentation = Api.GetPresentation();
let slide = presentation.GetSlideByIndex(0);
let customGeometry = Api.CreateCustomGeometry();
customGeometry.AddAdj("adj1", 25000);
customGeometry.SetAdjValue("adj1", 30000);
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(100, 150, 200));
let stroke = Api.CreateStroke(36000, Api.CreateSolidFill(Api.RGB(50, 75, 100)));
let shape = Api.CreateShape("rect", 100 * 36000, 100 * 36000, fill, stroke);
shape.SetGeometry(customGeometry);
shape.GetDocContent().GetElement(0).AddText("Adj value: " + customGeometry.GetAdjValue("adj1"));
shape.SetPosition(1500000, 1500000);
slide.AddObject(shape);