Documentation

mlreportgen.dom.DOCXPageFooter class

Package:mlreportgen.dom

页脚定义微软Word文档ument

Description

Add a footer to the first page of a Word document layout or to odd pages, even pages, or both.

Construction

docxPageFooterObj= DOCXPageFooter()creates an empty page footer based on the default Word template.

docxPageFooterObj= DOCXPageFooter(pageType,templatePath)creates an empty page footer for the specified type of page based on the specified template.

docxPageFooterObj= DOCXPageFooter(pageType,templatePath,docPartTemplateName)creates an empty page footer for the specified type of page, based on the specified document part template in the specified template.

docxPageFooterObj= DOCXPageFooter(pageType,templateSrc,docPartTemplateName)creates an empty 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.

Input Arguments

expand all

pageType— Type of pages the footer appears on[](default) |default|first|even

Type of pages the footer appears on, specified as one of these values:

  • default— If there are no page footers defined withpageTypeset tofirst, the footer appears on the odd pages of a section and on the first page.

  • first— Footer appears only on the first page of a section.

  • even— Footer appears on the even pages of a section.

For example, to make different footers appear on the first page and on even pages, define two footers. SetpageTypetofirstfor one and toevenfor the other.

templatePath— Full path of footer templatestring

Full path of footer template, specified as a string.

docPartTemplateName— Document part template namestring

Name of this part's template if it is stored in a template specified by thetemplatePathortemplateSrcargument, specified as a string.

templateSrc— Document or document part that holds the document part templatemlreportgen.dom.Documentobject |mlreportgen.dom.DocumentPartobject

Document or document part object whose template contains the template for this document part, specified as anmlreportgen.dom.Documentobject for a document or amlreportgen.dom.DocumentPartobject for a document part.

Output Arguments

expand all

docxPageFooterObj— Page footer for Word documentmlreportgen.dom.DOCXPageFooterobject

Page footer for a Word document, returned as anmlreportgen.dom.DOCXPageFooterobject.

Properties

expand all

ChildrenChildren of this objectcell array of objects

这个子元素的只读属性列表is object.

CurrentHoleIdID of current hole in documentstring

This read-only property is the hole ID of the current hole in this document.

CurrentHoleTypeType of current hole'Inline'|'Block'

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,AutoNumber.

  • A block hole can contain aParagraph,Table,OrderedList,UnorderedList,DocumentPart, orGroup.

IdID for document elementstring

A session-unique ID is generated as part of document element creation. You can specify an ID to replace the generated ID.

PageTypeType of pages on which footer appears[](default) |default|first|even

Type of page on which the footer appears, specified as one of these values:

  • default— If there are no page footers defined withpageTypeset tofirst, footer appears on odd pages in a section and the first page.

  • first— Appears only on the first page of a section.

  • even— Appears on even pages in a section.

To have a footer appear on the first page and on even pages, define two footers, one withpageTypeset tofirstand the other withpageTypeset toeven.

ParentParent of document elementDOM object

This read-only property lists the parent of this document element.

TagTag for document elementstring

Tag for document element, specified as a string.

A session-unique ID is generated as part of document element creation. The generated tag has the formCLASS:ID, whereCLASSis the class of the element andIDis the value of theIdproperty of the object. You can specify a tag to replace the generated tag.

For example, to make it easier to identify where an issue occurred during document generation, you can specify your own tag value.

TemplatePathPath to template used for footerstring

Full path to the template to use for this footer, specified as a string.

Methods

UseDocumentPageFootermethods like you use the correspondingDocumentmethods.

Method

Purpose

append

Append one of these DOM objects to the footer:

  • CustomElement

  • FormalTable

  • Group

  • ExternalLink

  • Image

  • InternalLink

  • OrderedList

  • Paragraph

  • RawText

  • Table

  • Text

  • UnorderedList

close

Close the footer.

fill

Fill the template hole.

moveToNextHole

Move to the next template hole.

open

Open the footer.

Examples

expand all

Add Footer to Word Document

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.

importmlreportgen.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 layoutfirstfooter = DOCXPageFooter('first'); evenfooter = DOCXPageFooter('even'); oddfooter = DOCXPageFooter('default'); d.CurrentPageLayout.PageFooters = [firstfooter,evenfooter,oddfooter];% Add title to first page footerp = Paragraph('My Document Title'); p.HAlign ='center'; append(d.CurrentPageLayout.PageFooters(1),p);% Add page number to even page footer% Align even page numbers leftpg2 = 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 rightpg3 = 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);

Related Examples

Was this topic helpful?