Main Content

mlreportgen.dom.PageNumber class

Package: mlreportgen.dom

Format page numbers

Description

Specifies the initial value of a page number in a Word page layout and the type of number, such as roman numerals. Set this property as a style on a DOCXPageLayout or a PDFPageLayout object. Insert the page number in a page layout object using mlreportgen.dom.Page to see the effect of this format.

This object enables you to create compound page numbers in the form [Chapter #]–[Page#] and specify the separator. For an example, see Add Complex Page Numbers in Microsoft Word.

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

Creation

Description

pgnum = PageNumber() specifies a numeric page number whose value continues from the previous page.

pgnum = PageNumber(number) sets the initial value to the specified number.

example

pgnum = PageNumber(number,format) uses the specified type of number, such as roman numerals.

Input Arguments

expand all

Number of first page in this layout, specified as a positive integer.

Type of page numbering to use, specified as one of these values.

ValueMeaningApplies To
DOCXPDF
'a'Lowercase alphabetic
'A'Uppercase alphabetic
'i'Lowercase Roman numerals
'I'Uppercase Roman numerals
'n'. 'N' , '1', 'decimal'Arabic numerals
'numberInDash'Number with dashes on either side 
'hebrew1'Hebrew numerals 
'hebrew2'Hebrew alphabetic 
'arabicAlpha'Arabic alphabetic 
'arabicAbjad'Arabic abjad numerals 
'thaiLetters'Thai letters 
'thaiNumbers'Thai numerals  
'thaiCounting'Thai counting system 

Properties

expand all

Character to use to separate the chapter number from the page number, specified as one of these values:

  • 'colon' or ';'— Colon.

  • 'hyphen' or '-'— Hyphen.

  • 'emdash'— Em dash (—).

  • 'endash'— En dash (–).

  • 'period' or '.'— Period.

Level of Heading style that chapters use, specified as a positive integer character vector.

Type of page numbering to use, specified as one of the character vectors or string scalars in the table.

ValueMeaningApplies To
DOCXPDF
'a'Lowercase alphabetic
'A'Uppercase alphabetic
'i'Lowercase Roman numerals
'I'Uppercase Roman numerals
'n'. 'N', '1', 'decimal'Arabic numerals
'numberInDash'Number with dashes on either side 
'hebrew1'Hebrew numerals 
'hebrew2'Hebrew alphabetic 
'arabicAlpha'Arabic alphabetic 
'arabicAbjad'Arabic abjad numerals 
'thaiLetters'Thai letters 
'thaiNumbers'Thai numerals  
'thaiCounting'Thai counting system 

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.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

Value of first page number in this layout, specified as a positive integer.

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.

Attributes:

GetAccess
public
SetAccess
public
NonCopyable
true

Data Types: char | string

Examples

collapse all

This example shows the syntax for using PageNumber, which you set using PageNumber as a style on the current page layout. For the numbering to take effect, you need to insert a page number into a page footer or header using Page,and you need to use a multilevel list style in the Word template. For a complete example, see Add Complex Page Numbers in Microsoft Word

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

open(d);
layout = d.CurrentPageLayout;

% Start on page 7 and use roman numerals
pagenumber = PageNumber(7,'I');

% Add page number object to page layout styles
layout.Style = [layout.Style {pagenumber}];

% Create the footer and add a page number to it
myfooter = DOCXPageFooter();
para = Paragraph();
para.HAlign = 'center';
append(para,Page());

% Add the page number to the footer
append(myfooter,para);
layout.PageFooters = myfooter;

% Add content
append(d,'Hello World');

close(d);
rptview(d);

Version History

Introduced in R2016a