Main Content

mlreportgen.dom.PageMargins Class

Namespace: mlreportgen.dom

Page margins for Microsoft Word and PDF page layout

Description

Use an object of the mlreportgen.dom.PageMargins class to specify the size of the page margins of a section of a Microsoft® Word or PDF report.

Creation of page headers and footers differs between Word and PDF documents. 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 type.

In addition, top and bottom margins are handled differently for different output types. 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 of the body text.

The mlreportgen.dom.PageMargins class is a handle class.

Class Attributes

HandleCompatible
true
ConstructOnLoad
true

For information on class attributes, see Class Attributes.

Creation

Description

pageMarginsObj = mlreportgen.dom.PageMargins creates a PageMargins object with properties that specify 1-inch top, bottom, left, and right margins, a 0.5-inch header and footer, and a 0-pixel gutter.

example

Properties

expand all

Top margin size, specified as a character vector or string scalar that consists of a number followed by an abbreviation for a unit of measurement. For example, "1in" specifies 1 inch. Valid abbreviations are:

  • "px" — pixels

  • "cm" — centimeters

  • "in" — inches

  • "mm" — millimeters

  • "pc" — picas

  • "pt" — points

Bottom margin size, specified as a character vector or string scalar that consists of a number followed by an abbreviation for a unit of measurement. For example, "1in" specifies 1 inch. Valid abbreviations are:

  • "px" — pixels

  • "cm" — centimeters

  • "in" — inches

  • "mm" — millimeters

  • "pc" — picas

  • "pt" — points

Left margin size, specified as a character vector or string scalar that consists of a number followed by an abbreviation for a unit of measurement. For example, "1in" specifies 1 inch. Valid abbreviations are:

  • "px" — pixels

  • "cm" — centimeters

  • "in" — inches

  • "mm" — millimeters

  • "pc" — picas

  • "pt" — points

Right margin size, specified as a character vector or string scalar that consists of a number followed by an abbreviation for a unit of measurement. For example, "1in" specifies 1 inch. Valid abbreviations are:

  • "px" — pixels

  • "cm" — centimeters

  • "in" — inches

  • "mm" — millimeters

  • "pc" — picas

  • "pt" — points

Header size, specified as a character vector or string scalar that consists of a number followed by an abbreviation for a unit of measurement. For example, "0.5in" specifies 0.5 inches. Valid abbreviations are:

  • "px" — pixels

  • "cm" — centimeters

  • "in" — inches

  • "mm" — millimeters

  • "pc" — picas

  • "pt" — points

Gutter size, specified as a character vector or string scalar that consists of a number followed by an abbreviation for a unit of measurement. For example, "0px" specifies 0 pixels. Valid abbreviations are:

  • "px" — pixels

  • "cm" — centimeters

  • "in" — inches

  • "mm" — millimeters

  • "pc" — picas

  • "pt" — points

Tag for the mlreportgen.dom.PageMargins object, specified as a character vector or string scalar. The DOM API 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. Specify your own tag value to help you identify where to look when an issue occurs during document generation.

Attributes:

NonCopyable
true

Data Types: char | string

Object identifier for the mlreportgen.dom.PageMargins object, specified as a character vector or string scalar. The DOM API generates a session-unique identifier when it creates the document element object. You can specify your own value for Id.

Attributes:

NonCopyable
true

Data Types: char | string

Examples

collapse all

In the PageMargins object associated with the document layout object, specify 0.5-inch margins.

import mlreportgen.dom.*;
d = Document('myreport','docx');
open(d);
 
pageLayoutObj = d.CurrentPageLayout;
pageLayoutObj.PageMargins.Left  = '0.5in';
pageLayoutObj.PageMargins.Right = '0.5in';
append(d,'Left and right margins are 0.5 inches.');

close(d);
rptview(d);

Use an mlreportgen.dom.PageMargins object to specify 0.5-inch margins. Assign the object to the PageMargins property of the report layout object.

import mlreportgen.report.*;
import mlreportgen.dom.*;

rpt = Report('myreport','docx');
open(rpt);
 
pageMarginsObj = PageMargins();
pageMarginsObj.Left = '0.5in';
pageMarginsObj.Right = '0.5in';
rpt.Layout.PageMargins = pageMarginsObj;

append(rpt,'Left and right margins are 0.5 inches.');
close(rpt);
rptview(rpt);

Version History

Introduced in R2016a