addHeaderSection
- addBibliography
- addBookmark
- addBreak
- addChart
- addCitation
- addComment
- addCrossReference
- addDateAndHour
- addEndnote
- addExternalFile
- addFootnote
- addFormElement
- addHeading
- addImage
- addLink
- addList
- addMathEquation
- addMergeField
- addOLE
- addOnlineVideo
- addPageNumber
- addShape
- addSimpleField
- addSource
- addStructuredDocumentTag
- addSVG
- addTab
- addTable
- addTableContents
- addTableFigures
- addText
- addTextBox
- addWordFragment
- addWordML
- embedHTML
- addBackgroundImage
- addFooter
- addFooterSection
- addHeader
- addHeaderSection
- addLineNumbering
- addMacroFromDoc
- addPageBorders
- addProperties
- addSection
- createDocx
- createDocxAndDownload
- createCharacterStyle
- createListStyle
- createParagraphStyle
- createTableStyle
- docxSettings
- embedFont
- importChartStyle
- importHeadersAndFooters
- importListStyle
- importStyles
- importStylesWordDefault
- modifyPageLayout
- parseStyles
- removeFooters
- removeHeaders
- setBackgroundColor
- setDefaultFont
- setDocumentDefaultStyles
- setEncodeUTF8
- setLanguage
- setMarkAsFinal
- setRTL
- clearBlocks
- cloneBlock
- deleteBlock
- getTemplateVariables
- getTemplateVariablesType
- modifyInputFields
- modifyMergeFields
- processTemplate
- removeTemplateVariable
- removeTemplateVariableImage
- replaceBlock
- replaceListVariable
- replacePlaceholderImage
- replaceTableVariable
- replaceVariableByExternalFile
- replaceVariableByHtml
- replaceVariableByText
- replaceVariableByWordFragment
- replaceVariableByWordML
- setTemplateSymbol
- setTemplateBlockSymbol
- tickCheckboxes
addHeaderSection
![](/img/preview/methods_check.png)
![](/img/preview/methods_X.png)
Inserts headers in a specific section into the Word document.
Description
public addHeaderSection ( array $headers [, array $section = -1] [, array $options])
It is possible to include a different header for:
- the first page or title page.
- even pages.
- odd pages (this one is the default header for the whole document if no other headers are defined for the first or even pages).
The contents of the different headers are defined via the use of WordFragments. These header WordFragments allow for the insertion of:
- text paragraphs
- current date and/or hour
- images
- links
- lists
- page numbers
- shapes
- tables
- HTML content
- ...
You may also import the headers of an existing DOCX document via the ImportHeadersAndFooters method.
Parameters
headers
An array with the different header contents.
Key | Type | Description |
---|---|---|
default | WordFragment | The WordFragment object containing the contents for the default (odd pages) footer. |
even | WordFragment | The WordFragment object containing the contents for the even pages footer. |
first | WordFragment | The WordFragment object containing the contents for the first (title) page footer. |
section
Section position. -1 as default. 0 is the first section and -1 the last section.
options
An array with the available options.
The possible keys and values are:
key | Type | Description |
---|---|---|
removeOthers | bool | If true remove other headers in the section. Default as false. |
Exceptions
Method not available.
Not using WordFragments.
Section number doesn't exist.
Code samples
Release notes
- phpdocx 14.0:
- new method.