跳到主要内容

SetPageMargins

指定此节中所有页面的页边距。

语法

expression.SetPageMargins(nLeft, nTop, nRight, nBottom);

expression - 表示 ApiSection 类的变量。

参数

名称必需/可选数据类型默认值描述
nLeft必需twips左边距宽度,以点的二十分之一为单位(1/1440 英寸)。
nTop必需twips上边距高度,以点的二十分之一为单位(1/1440 英寸)。
nRight必需twips右边距宽度,以点的二十分之一为单位(1/1440 英寸)。
nBottom必需twips下边距高度,以点的二十分之一为单位(1/1440 英寸)。

返回值

boolean

示例

此示例指定此节中所有页面的页边距。

// How to set page margins.

// Update the margins of the page.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
paragraph.AddText("This is a page with margins set. ");
paragraph.AddText("The left margin is 5 inches wide (7200 twentieths of a point). ");
paragraph.AddText("The top margin is 2 inches high (2880 twentieths of a point). ");
paragraph.AddText("The right margin is 1 inch wide (1440 twentieths of a point). ");
paragraph.AddText("The bottom margin is 4 inches high (5760 twentieths of a point). ");
let section = doc.GetFinalSection();
section.SetPageMargins(7200, 2880, 1440, 5760);