跳到主要内容

SetParaPr

设置当前样式的段落属性。

语法

expression.SetParaPr(paraPr);

expression - 表示 ApiStyle 类的变量。

参数

名称必需/可选数据类型默认值描述
paraPr必需ApiParaPr将要设置的段落属性。

返回值

ApiStyle

示例

将段落格式规则应用于命名样式,以便文档中所有匹配的段落共享这些设置。

// How do I change the line spacing and alignment for all paragraphs that use a particular style in a document?

// Control indentation and spacing across multiple paragraphs at once by updating their shared style in a document.

let doc = Api.GetDocument();
let normalStyle = doc.GetDefaultStyle("paragraph");
let paraPr = Api.CreateParaPr();
paraPr.SetSpacingLine(480, "auto");
paraPr.SetJc("both");
normalStyle.SetParaPr(paraPr);

let paragraph = doc.GetElement(0);
paragraph.AddText("This is a paragraph with the line spacing, text justification and indent set using the paragraph style. ");
paragraph.AddText("We do not change the style of the paragraph itself. ");
paragraph.AddText("Only document-wide paragraph styles are applied.");
doc.Push(paragraph);