跳到主要内容

SetVertAlign

指定将应用于此段落内容相对于段落文本默认外观的对齐方式: -"baseline" - 当前段落中的字符将按默认文本基线对齐。 -"subscript" - 当前段落中的字符将对齐到默认文本基线下方。 -"superscript" - 当前段落中的字符将对齐到默认文本基线上方。

语法

expression.SetVertAlign(sType);

expression - 表示 ApiParagraph 类的变量。

参数

名称必需/可选数据类型默认值描述
sType必需"baseline" | "subscript" | "superscript"应用于文本内容的垂直对齐类型。

返回值

ApiParagraph | null

示例

在文档中创建两个段落,一个垂直对齐方式为 "subscript"(下标),另一个为 "superscript"(上标)。

// How to change a vertical alignment of a text run in a document.

// Create a new text run and make it subscript, baseline or superscript in a document.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
paragraph.AddText("This is a paragraph with the text aligned below the baseline vertically.");
paragraph.SetVertAlign("subscript");
paragraph = Api.CreateParagraph();
paragraph.AddText("This is a paragraph with the text aligned above the baseline vertically.");
paragraph.SetVertAlign("superscript");
doc.Push(paragraph);