mlreportgen.dom.DOCXPageFooter Class
R2026bNamespace: mlreportgen.dom
Page footer definition for Microsoft Word document
Description
Use an object of the mlreportgen.dom.DOCXPageFooter class to add a footer to the first page of a Word document layout or to odd pages,
even pages, or both.
This class is only compatible with this MATLAB®
Report Generator™ output type: "docx".
The mlreportgen.dom.DOCXPageFooter class is a handle class.
Creation
Description
creates a page footer based on the default Word template.docxFooter = DOCXPageFooter
creates a page footer for the specified type of page, that is, odd, even, or
first, based on the default Word template.docxFooter = DOCXPageFooter(pageType)
creates a page footer for the specified type of page based on the specified
template.docxFooter = DOCXPageFooter(pageType,templatePath)
creates a page footer for the specified type of page, based on the specified
document part template in the specified template.docxFooter = DOCXPageFooter(pageType,templatePath,docPartTemplateName)
creates a page footer for the specified type of page, based on the specified
document part template from the specified source. The source can be a
document or a document part.docxFooter = DOCXPageFooter(pageType,templateSrc,docPartTemplateName)
Input Arguments
Type of pages the footer appears on, specified as one of these values:
default— Footer for odd pages of the section, even pages if you do not specify an even-page footer, and first page if you do not specify a first-page footer.first— Footer for first page of a section.even— Footer for even pages of a section.
For example, to make different footers appear on odd pages and
on even pages, define two footers. Set pageType to default for
one and to even for the other.
Full path of footer template, specified as a string scalar or a character vector.
Data Types: char | string
Name of this part’s template if it is stored in a template
specified by the templatePath or templateSrc argument,
specified as a character vector or string scalar.
Document or document part object whose template contains the template for this document part,
specified as an mlreportgen.dom.Document object for a document or an
mlreportgen.dom.DocumentPart object for a document part.
Properties
Type of page on which the footer appears, specified as one of these values:
"default"— Footer for odd pages of the section, even pages if you do not specify an even-page footer, and first page if you do not specify a first-page footer."first"— Footer for first page of a section."even"— Footer for even pages in a section.
To have a footer appear on odd pages and on even pages, define two footers, one with
pageType set to "default" and the other with
pageType set to "even".
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: char | string
Full path of footer template, specified as a string scalar or a character vector.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: char | string
ID of the current hole in the document, specified as a character vector or string scalar.
Attributes:
GetAccess | public |
SetAccess | private |
Transient | true |
NonCopyable | true |
Data Types: char | string
Type of the current template hole, specified as "Inline" or
"Block".
An inline hole is for document elements that a paragraph element can contain:
Text,Image,LinkTarget,ExternalLink,InternalLink,CharEntity, orAutoNumber.A block hole can contain a
Paragraph,Table,OrderedList,UnorderedList,DocumentPart, orGroupelement.
Attributes:
GetAccess | public |
SetAccess | private |
Transient | true |
NonCopyable | true |
Data Types: char | string
Since R2026b
Template holes mapped by ID number, returned as a dictionary mapping each hole ID in
the template to a hole content object. Use the hole ID as a key to access the
corresponding mlreportgen.dom.InlineHoleContent or
mlreportgen.dom.BlockHoleContent object, then call the
append method on the object to fill the hole with
content:
d.Holes("Title").append("My Report");
You cannot add, remove, or replace Holes dictionary entries.
Assigning a value to a hole entry or setting an entry to []
throws a MATLAB:class:SetProhibited error:
d.Holes("Title") = "My Report"; % Error: MATLAB:class:SetProhibited
An inline hole occurs in a paragraph. You can append only objects that a paragraph can contain, such as text and images. A block hole can contain block-level elements such as paragraphs, tables, and lists.
If your code calls moveToNextHole, fill each hole through
Holes before advancing past that hole. After
moveToNextHole advances past a hole, appending content to that
hole causes a holeContentCannotAppend error. For details, see mlreportgen.dom.InlineHoleContent or mlreportgen.dom.BlockHoleContent.
Attributes:
GetAccess | public |
SetAccess | private |
Data Types: dictionary
This property does not apply to page footers.
Attributes:
GetAccess | public |
SetAccess | private |
Transient | true |
NonCopyable | true |
Parent of this object, specified as a document element object. A document element must have only one parent.
Attributes:
GetAccess | public |
SetAccess | private |
NonCopyable | true |
Children of this object, specified as an array of document element objects. This
property contains the document element objects appended using the
append method.
Attributes:
GetAccess | public |
SetAccess | private |
NonCopyable | true |
Tag, 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. Use this value to help identify
where an issue occurs during document generation.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: char | string
Object identifier, specified as a character vector or string scalar. The DOM API generates a session-unique identifier when it creates the document element object.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Data Types: char | string
Methods
Method | Purpose |
|---|---|
append |
Input Arguments
Return Values
To see a list of
the Document Object Model (DOM) class objects and MATLAB data
types you can use as the
For more information, see the equivalent |
close | Close the footer |
fill | Fill the template hole |
moveToNextHole | Move to the next template hole |
open | Open the footer |
Examples
This example defines first, even, and odd page footers in a Word document. It inserts a page number in each footer, using a different alignment for each page type.
import mlreportgen.dom.*; d = Document('mydoc','docx'); open(d); % Create page footer objects for each type of page % Assign a matrix of page footer objects to the current page layout firstfooter = DOCXPageFooter('first'); evenfooter = DOCXPageFooter('even'); oddfooter = DOCXPageFooter('default'); d.CurrentPageLayout.PageFooters = [firstfooter,evenfooter,oddfooter]; % Add title to first page footer p = Paragraph('My Document Title'); p.HAlign = 'center'; append(d.CurrentPageLayout.PageFooters(1),p); % Add page number to even page footer % Align even page numbers left pg2 = Page(); p2 = Paragraph(); p2.HAlign = 'left'; append(p2,pg2); append(d.CurrentPageLayout.PageFooters(2),p2); % Add page number to odd page footer % Align odd page numbers right pg3 = Page(); p3 = Paragraph(); p3.HAlign = 'right'; append(p3,pg3); append(d.CurrentPageLayout.PageFooters(3),p3); % Create several pages. p = Paragraph('Hello World'); append(d,p); p = Paragraph('Another page'); p.Style = {PageBreakBefore(true)}; append(d,p); append(d,clone(p)); close(d); rptview(d.OutputPath);
More About
You can append these DOM objects to an
mlreportgen.dom.DOCXPageFooter object:
You can append these MATLAB data types to an
mlreportgen.dom.DOCXPageFooter object:
character array — Appends and returns a
mlreportgen.dom.Textobjectstring scalar — Appends and returns a
mlreportgen.dom.Textobjectnumeric variable — Appends and returns a
mlreportgen.dom.Numberobjectlogical variable — Appends and returns a
mlreportgen.dom.Numberobject with a value of1or01D horizontal array of double values or strings — Appends and returns a
mlreportgen.dom.UnorderedListobject1D string array — Appends and returns a
mlreportgen.dom.UnorderedListobject1D categorical array — Appends and returns a
mlreportgen.dom.UnorderedListobject2D array of double values or strings — Appends and returns a
mlreportgen.dom.Tableobject2D array of strings — Appends and returns a
mlreportgen.dom.Tableobject2D categorical array — Appends and returns a
mlreportgen.dom.TableobjectMATLAB table — Appends and returns a
mlreportgen.dom.MATLABTableobject
Version History
Introduced in R2014bThe Holes property provides direct access to template holes by ID.
Use the hole ID as a dictionary key to access the corresponding hole content object, then
call the append method to fill the hole with content. This approach
eliminates the need to iterate through holes to find a specific ID.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)