跳到主要内容

SetVerPosition

设置浮动对象垂直定位的绝对测量值。

语法

expression.SetVerPosition(sRelativeFrom, nDistance, bPercent);

expression - 表示 ApiDrawing 类的变量。

参数

名称必需/可选数据类型默认值描述
sRelativeFrom必需RelFromV将作为对象垂直对齐参考点的文档元素。
nDistance必需EMU | number从文档元素底部到浮动对象的距离。使用 EMU 表示绝对单位,或当 bPercent=true 时使用数字(1 = 1%)表示百分比相对定位。
bPercent可选booleanfalse定义垂直对齐偏移量是否以百分比指定的选项。

返回值

boolean

示例

此示例设置浮动对象垂直定位的绝对测量值。

// How to set the vertical position at page in points.

// Move the shape vertically on the page.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
paragraph.AddText("This is a paragraph with a shape. ");
paragraph.AddText("The text wraps the rectangular box that bounds the object. ");
paragraph.AddText("The distance between the shape and the text (horizontally) is half an inch (457200 English measure units).");
let gs1 = Api.CreateGradientStop(Api.RGB(255, 213, 191), 0);
let gs2 = Api.CreateGradientStop(Api.RGB(255, 111, 61), 100000);
let fill = Api.CreateRadialGradientFill([gs1, gs2]);
let stroke = Api.CreateStroke(0, Api.CreateNoFill());
let drawing = Api.CreateShape("rect", 1908000, 1404000, fill, stroke);
drawing.SetDistances(457200, 457200, 457200, 0);
drawing.SetWrappingStyle("square");
drawing.SetVerPosition("page", 914400);
paragraph.AddDrawing(drawing);
paragraph = Api.CreateParagraph();
paragraph.AddText("The shape is aligned to the top of the page, and outstands from the page top 1 inch.");
doc.Push(paragraph);
paragraph = Api.CreateParagraph();
paragraph.AddText("The next blue shape is aligned vertically by 50% relative to the page.");
fill = Api.CreateSolidFill(Api.CreateRGBColor(91, 155, 213));
stroke = Api.CreateStroke(0, Api.CreateNoFill());
drawing = Api.CreateShape("rect", 1908000, 1404000, fill, stroke);
drawing.SetDistances(457200, 457200, 457200, 0);
drawing.SetWrappingStyle("square");
drawing.SetVerPosition("page", 50, true);
paragraph.AddDrawing(drawing);
doc.Push(paragraph);