Main Content

mlreportgen.dom.PageNumber Class

Namespace: 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.

ValueMeaningSupported in DOCXSupported in PDF
'a'Lowercase alphabeticYesYes
'A'Uppercase alphabeticYesYes
'i'Lowercase Roman numeralsYesYes
'I'Uppercase Roman numeralsYesYes
'n'. 'N' , '1', 'decimal'Arabic numeralsYesYes
'numberInDash'Number with dashes on either sideYesNo
'hebrew1'Hebrew numeralsYesNo
'hebrew2'Hebrew alphabeticYesNo
'arabicAlpha'Arabic alphabeticYesNo
'arabicAbjad'Arabic abjad numeralsYesNo
'thaiLetters'Thai lettersYesNo
'thaiNumbers'Thai numerals YesNo
'thaiCounting'Thai counting systemYesNo

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 sideNo
'hebrew1'Hebrew numeralsNo
'hebrew2'Hebrew alphabeticNo
'arabicAlpha'Arabic alphabeticNo
'arabicAbjad'Arabic abjad numeralsNo
'thaiLetters'Thai lettersNo
'thaiNumbers'Thai numerals No
'thaiCounting'Thai counting systemNo

Object identifier for mlreportgen.dom.PageNumber 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

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

Tag for mlreportgen.dom.PageNumber 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

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