跳到主要内容

SetPageSize

Specifies the properties (size and orientation) for all the pages in the current section.

Syntax

expression.SetPageSize(nWidth, nHeight, isPortrait);

expression - A variable that represents a ApiSection class.

Parameters

NameRequired/OptionalData typeDefaultDescription
nWidthRequiredtwipsThe page width measured in twentieths of a point (1/1440 of an inch).
nHeightRequiredtwipsThe page height measured in twentieths of a point (1/1440 of an inch).
isPortraitOptionalbooleanfalseSpecifies the orientation of all the pages in this section (if set to true, then the portrait orientation is chosen).

Returns

boolean

Example

This example specifies the properties (size and orientation) for all the pages in the section.

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