跳到主要内容

SetPageMargins

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

语法

expression.SetPageMargins(left, top, right, bottom);

expression - 表示 ApiSection 类的变量。

参数

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

返回值

boolean

示例

设置文档中节内页面的上、下、左、右边距。

// How do I define the blank space around the edges of each page in a document?

// Adjust the border spacing on all sides of the pages within a section in a document.

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