SetVertAlign
指定将应用于文本块内容相对于文本块默认外观的对齐方式:
- “baseline” - 当前文本块中的字符将按默认文本基线对齐。
- “subscript” - 当前文本块中的字符将对齐到默认文本基线下方。
- “superscript” - 当前文本块中的字符将对齐到默认文本基线上方。
示例
在文档中将段落内的文本定位为下标、基线或上标。
// How do I raise or lower a portion of text relative to the surrounding line in a document?
// Distinguish chemical formulas or footnote markers by adjusting vertical text placement in a document.
let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
let run = Api.CreateRun();
run.AddText("This is just a sample text. ");
paragraph.AddElement(run);
let myNewRunStyle1 = doc.CreateStyle("My New Run Style 1", "run");
let textPr1 = myNewRunStyle1.GetTextPr();
textPr1.SetVertAlign("subscript");
run = Api.CreateRun();
run.SetStyle(myNewRunStyle1);
run.AddText("This is a text run with the text aligned below the baseline vertically. ");
paragraph.AddElement(run);
let myNewRunStyle2 = doc.CreateStyle("My New Run Style 2", "run");
let textPr2 = myNewRunStyle2.GetTextPr();
textPr2.SetVertAlign("baseline");
run = Api.CreateRun();
run.SetStyle(myNewRunStyle2);
run.AddText("This is a text run with the text aligned by the baseline vertically. ");
paragraph.AddElement(run);
let myNewRunStyle3 = doc.CreateStyle("My New Run Style 3", "run");
let textPr3 = myNewRunStyle3.GetTextPr();
textPr3.SetVertAlign("superscript");
run = Api.CreateRun();
run.SetStyle(myNewRunStyle3);
run.AddText("This is a text run with the text aligned above the baseline vertically.");
paragraph.AddElement(run);