PageMargin Class

Page Margins.When the object is serialized out as xml, its qualified name is w:pgMar.

Inheritance Hierarchy

System.Object
  DocumentFormat.OpenXml.OpenXmlElement
    DocumentFormat.OpenXml.OpenXmlLeafElement
      DocumentFormat.OpenXml.Wordprocessing.PageMargin

Namespace:  DocumentFormat.OpenXml.Wordprocessing
Assembly:  DocumentFormat.OpenXml (in DocumentFormat.OpenXml.dll)

Syntax

'Declaration
Public Class PageMargin _
    Inherits OpenXmlLeafElement
'Usage
Dim instance As PageMargin
public class PageMargin : OpenXmlLeafElement

Remarks

[ISO/IEC 29500-1 1st Edition]

17.6.11 pgMar (Page Margins)

This element specifies the page margins for all pages in this section.

[Example: Consider a page with a one-inch margin on all sides. Specifying these margins requires the following WordprocessingML:

<w:sectPr>
<w:pgMar w:header="720" w:bottom="1440" w:top="1440" w:right="1440" w:left="1440"/>
…
</w:sectPr>

This section specifies page margins of 1,440 twentieths of a point (one inch) on all sides. end example]

Parent Elements

sectPr (§17.6.17); sectPr (§17.6.18); sectPr (§17.6.19)

Attributes

Description

bottom (Page Bottom Spacing)

Specifies the distance (in twentieths of a point) between the bottom of the text margins for the main document and the bottom of the page for all pages in this section.

If the value of bottom is non-negative, then the text is placed at the greater of:

  • The value of bottom

  • The extent of the footer text

[Example: Consider a document where the footer must start one inch of the bottom of the page extent, but the contents of the main document story specify that they must start one-half of an inchh from the page extents. To specify these boundaries, the following page margins can specified in the WordprocessingML:

<w:pgMar … w:bottom="720"
w:footer="1440"/>

This fragment specifies that the footer must start 1440 twentieths of a point from the bottom of the page, but the main document story must start 720 twentieths of a point from the bottom of the page. Since the footer extent is guaranteed to be greater in this case, the bottom text extent ends at the top of the footer region. end example]

A negative value indicates that the contents of the main document shall be measured from the bottom of the page extent regardless of the footer for that document, and therefore shall overlap the footer text.

[Example: Consider a document where the footer must start one inch of the bottom of the page extent, but the contents of the main document story must start one-half of an inch from the page extents. To specify these boundaries, the following page margins can be specified in the WordprocessingML:

<w:pgMar … w:bottom="-720"
w:footer="1440"/>

This fragment specifies that the footer must start 1440 twentieths of a point from the bottom of the page, and the main document story must start 720 twentieths of a point from the bottom of the page. Since the value of bottom is negative in this case, the bottom text extent starts one-half of an inch from the bottom of the page and overlaps any footer text. end example]

The possible values for this attribute are defined by the ST_SignedTwipsMeasure simple type (§17.18.81).

footer (Spacing to Bottom of Footer)

Specifies the distance (in twentieths of a point) from the bottom edge of the page to the bottom edge of the footer.

[Example: Consider a document where the footer must start one inch above the bottom of the page extent.

To specify this boundary, the following page margins must specified in the WordprocessingML:

<w:pgMar … w:footer="1440"/>

This fragment specifies that the footer must start 1440 twentieths of a point from the bottom of the page. end example]

The possible values for this attribute are defined by the ST_TwipsMeasure simple type (§22.9.2.14).

gutter (Page Gutter Spacing)

Specifies the page gutter for each page in the current section.

The page gutter defines the amount of extra space added to the specified margin, above any existing margin values. [Note: This setting is typically used when a document is being created for binding, in order to ensure that the resulting margins are present after the binding gutter is consumed by the printed matter binding. end note]

[Example: Consider a document where the margin must start one inch of the left edge of the page extent after one-half of an inch is hidden by the page binding.

To specify this condition, a user could simply use a left margin of 1.5 inches, which would be lost if the margins are later changed, or could specify a one-half inch gutters follows in the WordprocessingML:

<w:pgMar … w:gutter="720"/>

This fragment specifies that the gutter must span 720 twentieths of a point, after which any margin value must be added. end example]

The possible values for this attribute are defined by the ST_TwipsMeasure simple type (§22.9.2.14).

header (Spacing to Top of Header)

Specifies the distance (in twentieths of a point) from the top edge of the page to the top edge of the header.

[Example: Consider a document where the header must start two inches below the top of the page extent. To specify this boundary, the following page margins must specified in the WordprocessingML:

<w:pgMar … w:header="2880"/>

This fragment specifies that the header must start 2880 twentieths of a point from the top of the page. end example]

The possible values for this attribute are defined by the ST_TwipsMeasure simple type (§22.9.2.14).

left (Left Margin Spacing)

Specifies the distance (in twentieths of a point) between the left edge of the page and the left edge of the text extents for this document.

[Example: Consider a document where the left text extent must start two inches inside the page extent. To specify this boundary, the following page margins must specified in the WordprocessingML:

<w:pgMar … w:left="2880"/>

This fragment specifies that the left margin must span 2880 twentieths of a point from the left edge of the page. end example]

The possible values for this attribute are defined by the ST_TwipsMeasure simple type (§22.9.2.14).

right (Right Margin Spacing)

Specifies the distance (in twentieths of a point) between the right edge of the page and the right edge of the text extents for this document.

[Example: Consider a document where the right text extent must start one inch inside the page.

To specify this boundary, the following page margins must specified in the WordprocessingML:

<w:pgMar … w:right="1440"/>

This fragment specifies that the right margin must span 1440 twentieths of a point from the right edge of the page. end example]

The possible values for this attribute are defined by the ST_TwipsMeasure simple type (§22.9.2.14).

top (Top Margin Spacing)

Specifies the distance (in twentieths of a point) between the top of the text margins for the main document and the top of the page for all pages in this section.

If the value of top is non-negative, then the text is placed at the greater of:

  • The value of top

  • The extent of the header text

[Example: Consider a document where the header must start one inch from the top of the page extent, but the contents of the main document story specify that they must start one-half of an inch from the page extents. To specify these boundaries, the following page margins can be specified in the WordprocessingML:

xm

This fragment specifies that the header must start 1440 twentieths of a point from the top of the page, but the main document story must start 720 twentieths of a point from the top of the page. Since the header extent is guaranteed to be greater in this case, the main text extent ends at the bottom of the header region. end example]

A negative value indicates that the contents of the main document shall be measured from the top of the page extent regardless of the header for that document, and therefore shall overlap the header text.

[Example: Consider a document where the header must start one inch from the top of the page extent, but the contents of the main document story must start one-half of an inch from the page extents. To specify these boundaries, the following page margins can be specified in the WordprocessingML:

<w:pgMar … w:top="-720"
w:header="1440"/>

This fragment specifies that the header must start 1440 twentieths of a point from the top of the page, and the main document story must start 720 twentieths of a point from the top of the page. Since the value of top is negative in this case, the top text extent starts one-half of an inch from the top of the page and overlaps any header text. end example]

The possible values for this attribute are defined by the ST_SignedTwipsMeasure simple type (§17.18.81).

[Note: The W3C XML Schema definition of this element’s content model (CT_PageMar) is located in §A.1. end note]

© ISO/IEC29500: 2008.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

PageMargin Members

DocumentFormat.OpenXml.Wordprocessing Namespace