跳到主要内容

SetTextPr

为当前范围设置文本属性。

语法

expression.SetTextPr(oTextPr);

expression - 表示 ApiRange 类的变量。

参数

名称必需/可选数据类型默认值描述
oTextPr必需ApiTextPr将应用于当前范围的文本属性。

返回值

ApiRange | null

示例

在文档中为选定范围应用完整的文本格式属性集。

// How do I copy formatting settings from one place and stamp them onto a text range in a document?

// Transfer font style, size, and other attributes onto a chosen portion of text in a document.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
paragraph.AddText("ONLYOFFICE Document Builder");
let textPr = paragraph.GetTextPr();
textPr.SetItalic(true);
let range = doc.GetRange(0, 24);
range.SetTextPr(textPr);