mlreportgen.dom.PageNumber class

Package: mlreportgen.dom
Superclasses:

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.

Construction

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.

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 

Output Arguments

expand all

Page number format, returned as an mlreportgen.dom.PageNumber object.

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 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 

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

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

Tag for the document element, specified as a character vector.

The DOM generates a session-unique tag when it creates the document element. Structure the tag as class:id, where class is the class of the element and id is the value of the Id property. You can specify a tag to replace the generated tag. Specifying your own tag can make it easier to identify where an issue occurred during document generation.

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.OutputPath);