Main Content

mlreportgen.dom.PageMargins class

Package: mlreportgen.dom
Superclasses:

Page margins for Microsoft Word and PDF page layout

Description

Specifies the size of the page margins of a section of a Microsoft® Word or PDF document.

Word and PDF formats create page headers and footers differently. For example, PDF page headers and footers are fixed in size. Word headers and footers expand to fit the content. Therefore, the appearance of top and bottom page margins using the same values can differ based on the output format.

In addition, each format handles top and bottom margins differently. These differences can result in different page breaks even with the same margin settings.

  • For PDF, the total height of the top margin equals the value of the Top property of this object plus the height of the Header property. The body text starts below the header. For Word documents, the top margin and header expand to prevent overlapping of the header and the body text.

  • Similarly, the total height of the PDF bottom margin equals the value of the Bottom property of this object plus the height of the Footer property. The body text ends above the footer. For Word documents, the footer expands to prevent overlapping the body text.

Construction

PageMarginsObj = PageMargins() specifies default page margins, which are one inch for the top, bottom, left, and right margins, one-half inch for the header and footer, and zero pixels for the gutter.

Output Arguments

expand all

Page margins, returned as an mlreportgen.dom.PageMargins object.

Properties

expand all

Width of the bottom margin, specified in the form valueUnits, where Units is an abbreviation for the units. Valid abbreviations are:

  • px — pixels (default)

  • cm — centimeters

  • in — inches

  • mm — millimeters

  • pc — picas

  • pt — points

Gutter size, specified in the form valueUnits, where Units is an abbreviation for the units to use. Valid abbreviations are:

  • px — pixels (default)

  • cm — centimeters

  • in — inches

  • mm — millimeters

  • pc — picas

  • pt — points

Header size, specified in the form valueUnits, where Units is an abbreviation for the units. Valid abbreviations are:

  • px — pixels (default)

  • cm — centimeters

  • in — inches

  • mm — millimeters

  • pc — picas

  • pt — points

ID for this document element, specified as a character vector or string scalar. The DOM generates a session-unique ID when it creates the document element. You can specify your own ID.

Left margin size, specified in the form valueUnits, where Units is an abbreviation for the units. Valid abbreviations are:

  • px — pixels (default)

  • cm — centimeters

  • in — inches

  • mm — millimeters

  • pc — picas

  • pt — points

Right margin size, specified in the form valueUnits, where Units is an abbreviation for the units. Valid abbreviations are:

  • px — pixels (default)

  • cm — centimeters

  • in — inches

  • mm — millimeters

  • pc — picas

  • pt — points

Tag for this document element, specified as a character vector or string scalar.

The DOM generates a session-unique tag as part of the creation of this object. The generated tag has the form CLASS:ID, where CLASS is the object class and ID is the value of the Id property of the object. Specifying your own tag value can help you to identify where an issue occurred during document generation.

Top margin size, specified in the form valueUnits, where Units is an abbreviation for the units. Valid abbreviations are:

  • px — pixels (default)

  • cm — centimeters

  • in — inches

  • mm — millimeters

  • pc — picas

  • pt — points

Examples

collapse all

Set the left and right margins for the current page layout to .5 inches.

import mlreportgen.dom.*;
d = Document('myreport','docx');
open(d);

s = d.CurrentPageLayout;
s.PageMargins.Left  = '.5in';
s.PageMargins.Right = '.5in';
append(d,'Left and right margins are .5 inch');

close(d);
rptview(d.OutputPath);
Introduced in R2016a