Documentation

Header extends Footer
in package

Header element.

Table of Contents

Constants

AUTO  = 'default'
Header/footer types constants.
EVEN  = 'even'
FIRST  = 'first'

Properties

$collectionRelation  : bool
Is part of collection; true for Title, Footnote, Endnote, Chart, and Comment.
$commentsRangeEnd  : Comments
The end position for the linked comments.
$commentsRangeStart  : Comments
The start position for the linked comments.
$container  : string
Container type Section|Header|Footer|Footnote|Endnote|Cell|TextRun|TextBox|ListItemRun|TrackChange.
$docPart  : string
Document part type: Section|Header|Footer|Footnote|Endnote.
$docPartId  : int
Document part Id.
$elementId  : string
Unique Id for element.
$elementIndex  : int
Index of element in the elements collection (start with 1).
$elements  : array<string|int, AbstractElement>
Elements collection.
$mediaRelation  : bool
Has media relation flag; true for Link, Image, and Object.
$phpWord  : PhpWord|null
PhpWord object.
$relationId  : int
Relation Id.
$sectionId  : int
Section Id.
$type  : string
Header type.
$nestedLevel  : int
Depth of table container nested level; Primarily used for RTF writer/reader.
$parent  : null|AbstractElement
A reference to the parent.
$parentContainer  : string
Parent container type.
$trackChange  : TrackChange
changed element info.

Methods

__call()  : AbstractElement
Magic method to catch all 'addElement' variation.
__construct()  : mixed
Create new instance.
addBookmark()  : Bookmark
addChart()  : Chart
addCheckBox()  : CheckBox
addEndnote()  : Endnote
addField()  : Field
addFootnote()  : Footnote
addFormField()  : FormField
addFormula()  : Formula
addImage()  : Image
addLine()  : Line
addLink()  : Link
addListItem()  : ListItem
addListItemRun()  : ListItemRun
addObject()  : OLEObject
addOLEObject()  : OLEObject
addPageBreak()  : PageBreak
addPreserveText()  : PreserveText
addSDT()  : SDT
addShape()  : Shape
addTable()  : Table
addText()  : Text
addTextBox()  : TextBox
addTextBreak()  : void
addTextRun()  : TextRun
addTitle()  : Title
addTOC()  : TOC
addWatermark()  : Image
Add a Watermark Element.
countElements()  : int
Count elements.
evenPage()  : string
Even numbered pages only.
firstPage()  : string
First page only header.
getCommentRangeEnd()  : Comment
Get comment end.
getCommentRangeStart()  : Comment
Get comment start.
getCommentsRangeEnd()  : Comments
Get comments end.
getCommentsRangeStart()  : Comments
Get comments start.
getDocPart()  : string
Get doc part.
getDocPartId()  : int
Get doc part Id.
getElement()  : null|AbstractElement
Returns the element at the requested position.
getElementId()  : string
Get element unique ID.
getElementIndex()  : int
Get element index.
getElements()  : array<string|int, AbstractElement>
Get all elements.
getNestedLevel()  : int
Get nested level.
getParent()  : null|AbstractElement
Get parent element.
getPhpWord()  : PhpWord|null
Get PhpWord.
getRelationId()  : int
Get relation Id.
getSectionId()  : int
Get section number.
getTrackChange()  : TrackChange
Gets the trackChange information.
getType()  : string
Get type.
isInSection()  : bool
Check if element is located in Section doc part (as opposed to Header/Footer).
removeElement()  : void
Removes the element at requested index.
resetType()  : string
Reset type to default.
setChangeInfo()  : void
Set changed.
setCommentRangeEnd()  : void
Set comment end.
setCommentRangeStart()  : void
Set comment start.
setDocPart()  : void
Set doc part.
setElementId()  : void
Set element unique ID from 6 first digit of md5.
setElementIndex()  : void
Set element index.
setParentContainer()  : void
Set parent container.
setPhpWord()  : void
Set PhpWord as reference.
setRelationId()  : void
Set relation Id.
setTrackChange()  : void
Sets the trackChange information.
setType()  : void
Set type.
addElement()  : AbstractElement
Add element.
setEnumVal()  : null|string
Set enum value.
setNewStyle()  : mixed
Set new style value.
checkValidity()  : bool
Check if a method is allowed for the current container.
getMediaPart()  : string
Return media element (image, object, link) container name.
setCollectionRelation()  : void
Set relation Id for elements that will be registered in the Collection subnamespaces.
setMediaRelation()  : void
Set relation Id for media elements (link, image, object; legacy of OOXML).

Constants

FIRST

public mixed FIRST = 'first'

Properties

$collectionRelation

Is part of collection; true for Title, Footnote, Endnote, Chart, and Comment.

protected bool $collectionRelation = false

$container

Container type Section|Header|Footer|Footnote|Endnote|Cell|TextRun|TextBox|ListItemRun|TrackChange.

protected string $container = 'Header'

Container type

$docPart

Document part type: Section|Header|Footer|Footnote|Endnote.

protected string $docPart = 'Section'

Used by textrun and cell container to determine where the element is located because it will affect the availability of other element, e.g. footnote will not be available when $docPart is header or footer.

$docPartId

Document part Id.

protected int $docPartId = 1

For header and footer, this will be = ($sectionId - 1) * 3 + $index because the max number of header/footer in every page is 3, i.e. AUTO, FIRST, and EVEN (AUTO = ODD)

$elementIndex

Index of element in the elements collection (start with 1).

protected int $elementIndex = 1

$mediaRelation

Has media relation flag; true for Link, Image, and Object.

protected bool $mediaRelation = false

$type

Header type.

protected string $type = self::AUTO

$nestedLevel

Depth of table container nested level; Primarily used for RTF writer/reader.

private int $nestedLevel = 0

0 = Not in a table; 1 = in a table; 2 = in a table inside another table, etc.

$parentContainer

Parent container type.

private string $parentContainer

Methods

__call()

Magic method to catch all 'addElement' variation.

public __call(mixed $function, mixed $args) : AbstractElement

This removes addText, addTextRun, etc. When adding new element, we have to add the model in the class docblock with @method.

Warning: This makes capitalization matters, e.g. addCheckbox or addcheckbox won't work.

Parameters
$function : mixed
$args : mixed
Return values
AbstractElement

__construct()

Create new instance.

public __construct(int $sectionId[, int $containerId = 1 ][, string $type = self::AUTO ]) : mixed
Parameters
$sectionId : int
$containerId : int = 1
$type : string = self::AUTO

addChart()

public addChart([string $type = ][, array<string|int, mixed> $categories = ][, array<string|int, mixed> $values = ][, array<string|int, mixed> $style = null ][, mixed $seriesName = null ]) : Chart
Parameters
$type : string =
$categories : array<string|int, mixed> =
$values : array<string|int, mixed> =
$style : array<string|int, mixed> = null
$seriesName : mixed = null
Return values
Chart

addCheckBox()

public addCheckBox([string $name = ][, mixed $text = ][, mixed $fStyle = null ][, mixed $pStyle = null ]) : CheckBox
Parameters
$name : string =
$text : mixed =
$fStyle : mixed = null
$pStyle : mixed = null
Return values
CheckBox

addField()

public addField([string $type = null ][, array<string|int, mixed> $properties = [] ][, array<string|int, mixed> $options = [] ][, mixed $text = null ]) : Field
Parameters
$type : string = null
$properties : array<string|int, mixed> = []
$options : array<string|int, mixed> = []
$text : mixed = null
Return values
Field

addFormField()

public addFormField([string $type = ][, mixed $fStyle = null ][, mixed $pStyle = null ]) : FormField
Parameters
$type : string =
$fStyle : mixed = null
$pStyle : mixed = null
Return values
FormField

addImage()

public addImage([string $source = ][, mixed $style = null ][, bool $isWatermark = false ][, mixed $name = null ]) : Image
Parameters
$source : string =
$style : mixed = null
$isWatermark : bool = false
$name : mixed = null
Return values
Image
public addLink([string $target = ][, string $text = null ][, mixed $fStyle = null ][, mixed $pStyle = null ][, bool $internal = false ]) : Link
Parameters
$target : string =
$text : string = null
$fStyle : mixed = null
$pStyle : mixed = null
$internal : bool = false
Return values
Link

addListItem()

public addListItem([string $txt = ][, int $depth = 0 ][, mixed $font = null ][, mixed $list = null ][, mixed $para = null ]) : ListItem
Parameters
$txt : string =
$depth : int = 0
$font : mixed = null
$list : mixed = null
$para : mixed = null
Return values
ListItem

addListItemRun()

public addListItemRun([int $depth = 0 ][, mixed $listStyle = null ][, mixed $pStyle = null ]) : ListItemRun
Parameters
$depth : int = 0
$listStyle : mixed = null
$pStyle : mixed = null
Return values
ListItemRun

addObject()

public addObject([string $source = ][, mixed $style = null ]) : OLEObject

deprecated, use addOLEObject instead

Parameters
$source : string =
$style : mixed = null
Return values
OLEObject

addOLEObject()

public addOLEObject([string $source = ][, mixed $style = null ]) : OLEObject
Parameters
$source : string =
$style : mixed = null
Return values
OLEObject

addPreserveText()

public addPreserveText([string $text = ][, mixed $fStyle = null ][, mixed $pStyle = null ]) : PreserveText
Parameters
$text : string =
$fStyle : mixed = null
$pStyle : mixed = null
Return values
PreserveText

addShape()

public addShape([string $type = ][, mixed $style = null ]) : Shape
Parameters
$type : string =
$style : mixed = null
Return values
Shape

addText()

public addText([string $text = ][, mixed $fStyle = null ][, mixed $pStyle = null ]) : Text
Parameters
$text : string =
$fStyle : mixed = null
$pStyle : mixed = null
Return values
Text

addTextBreak()

public addTextBreak([int $count = 1 ][, mixed $fStyle = null ][, mixed $pStyle = null ]) : void
Parameters
$count : int = 1
$fStyle : mixed = null
$pStyle : mixed = null

addTitle()

public addTitle([mixed $text = ][, int $depth = 1 ][, int $pageNumber = null ]) : Title
Parameters
$text : mixed =
$depth : int = 1
$pageNumber : int = null
Return values
Title

addTOC()

public addTOC([mixed $fontStyle = null ][, mixed $tocStyle = null ][, int $minDepth = 1 ][, int $maxDepth = 9 ]) : TOC
Parameters
$fontStyle : mixed = null
$tocStyle : mixed = null
$minDepth : int = 1
$maxDepth : int = 9
Return values
TOC

addWatermark()

Add a Watermark Element.

public addWatermark(string $src[, mixed $style = null ]) : Image
Parameters
$src : string
$style : mixed = null
Return values
Image

countElements()

Count elements.

public countElements() : int
Return values
int

evenPage()

Even numbered pages only.

public evenPage() : string
Return values
string

firstPage()

First page only header.

public firstPage() : string
Return values
string

getDocPart()

Get doc part.

public getDocPart() : string
Return values
string

getDocPartId()

Get doc part Id.

public getDocPartId() : int
Return values
int

getElementId()

Get element unique ID.

public getElementId() : string
Return values
string

getElementIndex()

Get element index.

public getElementIndex() : int
Return values
int

getNestedLevel()

Get nested level.

public getNestedLevel() : int
Return values
int

getRelationId()

Get relation Id.

public getRelationId() : int
Return values
int

getSectionId()

Get section number.

public getSectionId() : int
Return values
int

getType()

Get type.

public getType() : string
Tags
since
0.10.0
Return values
string

isInSection()

Check if element is located in Section doc part (as opposed to Header/Footer).

public isInSection() : bool
Return values
bool

resetType()

Reset type to default.

public resetType() : string
Return values
string

setChangeInfo()

Set changed.

public setChangeInfo(string $type, string $author[, null|DateTime|int $date = null ]) : void
Parameters
$type : string

INSERTED|DELETED

$author : string
$date : null|DateTime|int = null

allways in UTC

setDocPart()

Set doc part.

public setDocPart(string $docPart[, int $docPartId = 1 ]) : void
Parameters
$docPart : string
$docPartId : int = 1

setElementId()

Set element unique ID from 6 first digit of md5.

public setElementId() : void

setElementIndex()

Set element index.

public setElementIndex(int $value) : void
Parameters
$value : int

setParentContainer()

Set parent container.

public setParentContainer(self $container) : void

Passed parameter should be a container, except for Table (contain Row) and Row (contain Cell)

Parameters
$container : self

setPhpWord()

Set PhpWord as reference.

public setPhpWord([PhpWord|null $phpWord = null ]) : void
Parameters
$phpWord : PhpWord|null = null

setRelationId()

Set relation Id.

public setRelationId(int $value) : void
Parameters
$value : int

setType()

Set type.

public setType([string $value = self::AUTO ]) : void
Parameters
$value : string = self::AUTO
Tags
since
0.10.0

setEnumVal()

Set enum value.

protected setEnumVal([null|string $value = null ][, array<string|int, string> $enum = [] ][, null|string $default = null ]) : null|string
Parameters
$value : null|string = null
$enum : array<string|int, string> = []
$default : null|string = null
Tags
todo

Merge with the same method in AbstractStyle

Return values
null|string

setNewStyle()

Set new style value.

protected setNewStyle(mixed $styleObject[, null|array<string|int, mixed>|string|Style $styleValue = null ][, bool $returnObject = false ]) : mixed
Parameters
$styleObject : mixed

Style object

$styleValue : null|array<string|int, mixed>|string|Style = null

Style value

$returnObject : bool = false

Always return object

checkValidity()

Check if a method is allowed for the current container.

private checkValidity(string $method) : bool
Parameters
$method : string
Return values
bool

getMediaPart()

Return media element (image, object, link) container name.

private getMediaPart() : string
Return values
string

section|headerx|footerx|footnote|endnote

setCollectionRelation()

Set relation Id for elements that will be registered in the Collection subnamespaces.

private setCollectionRelation() : void

setMediaRelation()

Set relation Id for media elements (link, image, object; legacy of OOXML).

private setMediaRelation() : void
  • Image element needs to be passed to Media object
  • Icon needs to be set for Object element

        
On this page

Search results