跳到主要内容

GetTextPr

返回当前文本块的文本属性。

语法

expression.GetTextPr();

expression - 表示 ApiRun 类(文本块)的变量。

参数

此方法没有任何参数。

返回值

ApiTextPr

示例

此示例展示如何获取文本块的文本属性。

// How to change the text properties.

// Create a text object, set its font size, justification, etc.

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);