Get Started
Documentation

SetVerAlign

SetVerAlign(sRelativeFromopt, sAlignopt)

Specify how the floating object will be vertically aligned.

Parameters:

Name Type Attributes Default Description
sRelativeFrom RelFromV <optional>
"page" The document element which will be taken as a countdown point for the object vertical alignment.
sAlign "top" | "bottom" | "center" <optional>
"top" The alingment type which will be used for the object vertical alignment.

Example

Copy code
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oGs1, oGs2, oFill, oStroke, oDrawing, oParagraph;
oParagraph = oDocument.GetElement(0);
oParagraph.AddText("This is a paragraph with a shape. ");
oParagraph.AddText("The text wraps the rectangular box that bounds the object. ");
oParagraph.AddText("The distance between the shape and the text (horizontally) is half an inch (457200 English measure units).");
oGs1 = Api.CreateGradientStop(Api.CreateRGBColor(255, 224, 204), 0);
oGs2 = Api.CreateGradientStop(Api.CreateRGBColor(155, 64, 1), 100000);
oFill = Api.CreateRadialGradientFill([oGs1, oGs2]);
oStroke = Api.CreateStroke(0, Api.CreateNoFill());
oDrawing = Api.CreateShape("rect", 1908000, 1404000, oFill, oStroke);
oDrawing.SetDistances(457200, 457200, 457200, 0);
oDrawing.SetWrappingStyle("square");
oDrawing.SetVerAlign("page", "top");
oParagraph.AddDrawing(oDrawing);
oParagraph = Api.CreateParagraph();
oParagraph.AddText("The shape is aligned to the top of the page.");
oDocument.Push(oParagraph);
builder.SaveFile("docx", "SetVerAlign.docx");
builder.CloseFile();

Resulting document