Skip to main content

SetVertAlign

Specifies the alignment which will be applied to the Range contents in relation to the default appearance of the Range text: "baseline" - the characters in the current text Range will be aligned by the default text baseline. "subscript" - the characters in the current text Range will be aligned below the default text baseline. "superscript" - the characters in the current text Range will be aligned above the default text baseline.

Syntax​

expression.SetVertAlign(type);

expression - A variable that represents an ApiTextRange class.

Parameters​

NameRequired/OptionalData typeDefaultDescription
typeRequired"baseline" | "subscript" | "superscript" | nullThe vertical alignment type applied to the text contents. Pass null to remove the vertical alignment.

Returns​

ApiTextRange | null

Example​

Raise the text of a range above the baseline in a shape on a PDF page.

// Superscript and subscript are both set through this method.

// Turn the trailing digit into a superscript.

const doc = Api.GetDocument();
const page = doc.GetPage(0);

const fill = Api.CreateSolidFill(Api.RGB(255, 111, 61));
const stroke = Api.CreateStroke(0, Api.CreateNoFill());
const shape = Api.CreateShape("rect", 200 * 36000, 80 * 36000, fill, stroke);
shape.SetPosition(608400, 1267200);
page.AddObject(shape);

const docContent = shape.GetContent();
const paragraph = docContent.GetElement(0);
paragraph.AddText("E=mc2");

const range = shape.GetTextRange();

range.GetRange(4, 5).SetVertAlign("superscript");