跳到主要内容

SetPageSize

指定当前节中所有页面的属性(大小和方向)。

语法

expression.SetPageSize(nWidth, nHeight, isPortrait);

expression - 表示 ApiSection 类的变量。

参数

名称必需/可选数据类型默认值描述
nWidth必需twips页面宽度,以点的二十分之一为单位(1/1440 英寸)。
nHeight必需twips页面高度,以点的二十分之一为单位(1/1440 英寸)。
isPortrait可选booleanfalse指定此节中所有页面的方向(如果设置为 true,则选择纵向)。

返回值

boolean

示例

此示例指定节中所有页面的属性(大小和方向)。

// How to set page size.

// Get the final section and resize its page.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
paragraph.AddText("This is a page with a page size set. ");
paragraph.AddText("The page width is 5 inches (7200 twentieths of a point). ");
paragraph.AddText("The page height is 3 inches (4320 twentieths of a point). ");
paragraph.AddText("The font size is default (11 points).");
let section = doc.GetFinalSection();
section.SetPageMargins(720, 720, 720, 720);
section.SetPageSize(7200, 4320);