Get Started
Documentation

SetPageSize

SetPageSize(nWidth, nHeight, isPortraitopt)

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

Parameters:

Name Type Attributes Default Description
nWidth twips The page width measured in twentieths of a point (1/1440 of an inch).
nHeight twips The page height measured in twentieths of a point (1/1440 of an inch).
isPortrait boolean <optional> false Specifies the orientation of all pages in this section (if set to true then the portrait orientation is chosen).

Example

Copy code
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oParagraph, oHeader;
oParagraph = oDocument.GetElement(0);
oParagraph.AddText("This is a page with a page size set. ");
oParagraph.AddText("The page width is 5 inches (7200 twentieths of a point). ");
oParagraph.AddText("The page height is 3 inches (4320 twentieths of a point). ");
oParagraph.AddText("The font size is default (11 points).");
var oSection = oDocument.GetFinalSection();
oSection.SetPageMargins(720, 720, 720, 720);
oSection.SetPageSize(7200, 4320);
builder.SaveFile("docx", "SetPageSize.docx");
builder.CloseFile();

Resulting document