GetTextPr
返回当前文本块的文本属性。
语法
expression.GetTextPr();
expression - 表示 ApiRun 类(文本块)的变量。
参数
此方法没有任何参数。
返回值
示例
读取文档中应用于文本运行的文本格式设置。
// How do I retrieve the current text formatting of a run in a document?
// Inspect and reuse the styling options already set on a piece of text in a document.
let doc = Api.GetDocument();
let myNewRunStyle = doc.CreateStyle("My New Run Style", "run");
let textPr = myNewRunStyle.GetTextPr();
textPr.SetCaps(true);
textPr.SetFontFamily("Calibri Light");
let paragraph = doc.GetElement(0);
let run = Api.CreateRun();
run.AddText("This is just a sample text. ");
run.AddText("The text properties are changed and the style is added to the paragraph. ");
paragraph.AddElement(run);
run = Api.CreateRun();
run.SetStyle(myNewRunStyle);
run.AddText("This is a text run with its own style.");
paragraph.AddElement(run);