SetVerticalTextAlign
设置可以插入段落或文本块的形状内容的垂直对齐方式。
语法
expression.SetVerticalTextAlign(verticalAlign);
expression - 表示 ApiShape 类的变量。
参数
| 名称 | 必需/可选 | 数据类型 | 默认值 | 描述 |
|---|---|---|---|---|
| verticalAlign | 必需 | VerticalTextAlign | 形状内部内容的垂直对齐类型。 |
返回值
boolean
示例
在文档中将文本在形状内垂直定位。
// How do I align text to the top, middle, or bottom inside a shape in a document?
// Control where text sits vertically inside a shape container in a document.
let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
let fill = Api.CreateSolidFill(Api.RGB(255, 111, 61));
let stroke = Api.CreateStroke(0, Api.CreateNoFill());
let drawing = Api.CreateShape("rect", 3212465, 963295, fill, stroke);
paragraph.AddDrawing(drawing);
let docContent = drawing.GetContent();
let classType = drawing.GetClassType();
paragraph = Api.CreateParagraph();
paragraph.AddText("Class Type = " + classType);
docContent.AddElement(0, paragraph);
drawing.SetVerticalTextAlign("top");