w:pgSz (Page Size)
Specifies the width, height, and orientation of the page.
Parent elements
Description
w:pgSz sets the physical page dimensions and orientation for a section. It is defined in ECMA-376 Part 1 §17.6.13.
All measurements are in twips (1/20 of a point; 1440 twips = 1 inch). US Letter is w:w="12240" w:h="15840" (8.5×11”). A4 is w:w="11906" w:h="16838" (210×297 mm). When w:orient="landscape", applications swap width and height when rendering.
Attributes
| Attribute | Type | Possible Values | Description |
|---|---|---|---|
w:w |
ST_TwipsMeasure |
Positive integer (twips). | Page width. |
w:h |
ST_TwipsMeasure |
Positive integer (twips). | Page height. |
w:orient |
ST_PageOrientation |
portrait (default), landscape |
Page orientation. When landscape, w:w > w:h is expected. |
w:code |
xsd:unsignedShort |
Printer paper type code. | Vendor-defined paper size code for printer hardware. |
Examples
<!-- US Letter portrait (8.5" x 11") -->
<w:pgSz w:w="12240" w:h="15840"/>
<!-- A4 portrait (210 x 297 mm) -->
<w:pgSz w:w="11906" w:h="16838"/>
<!-- A4 landscape -->
<w:pgSz w:w="16838" w:h="11906" w:orient="landscape"/>
// US Letter portrait
new PageSize { Width = 12240, Height = 15840 };
// A4 portrait
new PageSize { Width = 11906, Height = 16838 };
// A4 landscape
new PageSize { Width = 16838, Height = 11906, Orient = PageOrientationValues.Landscape };
Extended Paper Size Reference
North American Sizes
| Size | Twips Width | Twips Height | Inches | mm | Notes | |——|—|—|—|—|—| | Letter | 12240 | 15840 | 8.5 × 11 | 216 × 279 | Standard US | | Legal | 12240 | 20160 | 8.5 × 14 | 216 × 356 | Long format | | Tabloid | 15840 | 24480 | 11 × 17 | 279 × 432 | Large format | | Ledger | 17280 | 11040 | 12 × 7.5 | 305 × 191 | Rotated tabloid | | Executive | 10440 | 15120 | 7.25 × 10.5 | 184 × 267 | Business letter |
ISO A-Series (International Standard)
| Size | Twips Width | Twips Height | mm | Ratio | |——|—|—|—|—| | A0 | 33842 | 47860 | 841 × 1189 | 1:√2 | | A1 | 23930 | 33842 | 594 × 841 | 1:√2 | | A2 | 16920 | 23930 | 420 × 594 | 1:√2 | | A3 | 11906 | 16920 | 297 × 420 | 1:√2 | | A4 | 11906 | 16838 | 210 × 297 | 1:√2 | | A5 | 8391 | 11906 | 148 × 210 | 1:√2 | | A6 | 5953 | 8391 | 105 × 148 | 1:√2 | | A7 | 4195 | 5953 | 74 × 105 | 1:√2 |
ISO B-Series (Intermediate Sizes)
| Size | Twips Width | Twips Height | mm | |——|—|—|—| | B4 | 14173 | 20090 | 250 × 353 | | B5 | 10047 | 14173 | 176 × 250 | | B6 | 7087 | 10047 | 125 × 176 |
ISO C-Series (Envelope Sizes)
| Size | Twips Width | Twips Height | mm | |——|—|—|—| | C4 | 12913 | 18248 | 229 × 324 | | C5 | 9124 | 12913 | 162 × 229 | | C6 | 6456 | 9124 | 114 × 162 |
Japanese Paper Sizes
| Size | Twips Width | Twips Height | mm | |——|—|—|—| | B4 JIS | 14287 | 20165 | 252 × 357 | | B5 JIS | 10083 | 14287 | 182 × 257 |
Chinese Paper Sizes
| Size | Twips Width | Twips Height | mm | |——|—|—|—| | 16K | 9779 | 14960 | 188 × 260 | | 32K | 7480 | 9779 | 130 × 184 |
Custom Page Size Examples
Business Card (3.5” × 2”)
<w:pgSz w:w="5040" w:h="2880" w:orient="landscape"/>
new PageSize
{
Width = 5040, // 3.5 inches
Height = 2880, // 2 inches
Orient = PageOrientationValues.Landscape
};
Postcard (6” × 4”)
<w:pgSz w:w="8640" w:h="5760" w:orient="landscape"/>
new PageSize
{
Width = 8640, // 6 inches
Height = 5760, // 4 inches
Orient = PageOrientationValues.Landscape
};
Booklet Half-Width (5.5” × 8.5”)
<w:pgSz w:w="7920" w:h="12240"/>
new PageSize
{
Width = 7920, // 5.5 inches
Height = 12240 // 8.5 inches (portrait)
};
Orientation Handling
Portrait Mode (narrow width, tall height):
<w:pgSz w:w="12240" w:h="15840" w:orient="portrait"/>
new PageSize
{
Width = 12240, // 8.5 inches (portrait)
Height = 15840, // 11 inches
Orient = PageOrientationValues.Portrait
};
Landscape Mode (wide width, narrow height):
<w:pgSz w:w="15840" w:h="12240" w:orient="landscape"/>
new PageSize
{
Width = 15840, // 11 inches (landscape)
Height = 12240, // 8.5 inches
Orient = PageOrientationValues.Landscape
};
When switching orientation, ensure width and height are swapped appropriately.
Conversion Reference
| 1 Inch | 1 mm | 1 Centimeter |
|---|---|---|
| 1440 twips | 56.7 twips | 567 twips |
| 1440 twips = 72 pt | 56.7 twips = 2.834 pt | 567 twips = 28.35 pt |
Quick Conversions:
- Inches to twips: multiply by 1440
- Twips to inches: divide by 1440
- mm to twips: multiply by 56.7
- Twips to mm: divide by 56.7
Notes
- Twips Conversion: 1440 twips = 1 inch; divide by 56.7 for millimeters.
- Orientation: When
w:orient="landscape", width should be greater than height. - A4 Standard: A4 (210 × 297 mm, 11906 × 16838 twips) is ISO standard, default in many countries outside North America.
- Section-Level: Different sections can have different page sizes; useful for mixed layouts.
- Printer Compatibility: Ensure selected page size is supported by target printer.
- Margin Interaction: Page size determines available text area after margins are applied; larger margins reduce usable space.
- Compatibility: Page sizes render consistently across all Office versions.
- Aspect Ratio: A-series paper maintains 1:√2 ratio (≈1:1.414) for consistent appearance when scaling.
- Custom Sizes: Most printers support custom page dimensions within hardware limits (typically 3”×5” to 14”×20”).
- Print Preview: Always check print preview for correct page size rendering before printing.