modifyPageLayout

modifyPageLayout

TRIAL / ADVANCED / PREMIUM

Modifies the Word document layout.

Description
public modifyPageLayout ( string $paperType [ array $options )

This method modifies the main layout properties of the Word document like paper type size and margins.

Parameters

paperType

The type of paper to be used. The possible values are:

  • A4
  • A3
  • letter
  • legal
  • A4-landscape
  • A3-landscape
  • letter-landscape
  • legal-landscape
  • custom

options

The possible keys and values are:

Key Type Description
height int Document height in twips (twentieths of a point).
width int Document width in twips (twentieths of a point).
marginTop int Top margin in twips (twentieths of a point).
marginRight int Right margin in twips (twentieths of a point).
marginBottom int Bottom margin in twips (twentieths of a point).
marginLeft int Left margin in twips (twentieths of a point).
marginHeader int Header margins in twips (twentieths of a point).
marginFooter int Footer margins in twips (twentieths of a point).
numberCols int Number of columns.
orient string Page orientation (portrait or landscape).
space int Column spacing in twips (twentieths of a point).
gutter int Gutter in twips (twentieths of a point). The gutter is only used for binding.
bidi string Set to 'on' for right to left languages (default value is 'off').
rtlGutter string Set to 'on' for right to left languages (default value is 'off').
onlyLastSection bool If true it only modifies the last section (default value is false).
sectionNumbers array An array with the sections that you want to modify.
pageNumberType array Keys and values:
  • fmt => number format (cardinalText, decimal, decimalEnclosedCircle, decimalEnclosedFullstop, decimalEnclosedParen, decimalZero, lowerLetter, lowerRoman, none, ordinalText, upperLetter, upperRoman)
  • start => page number
columns array Keys and values:
  • width (int)
  • space (int)
endnotes array Keys and values:
  • numFmt (string) => numbering format: decimal, upperRoman, lowerRoman, upperLetter...
  • numRestart (string) => continuous, eachSect, eachPage
  • numStart (int) => starting value
  • pos (string) => sectEnd, docEnd
footnotes array Keys and values:
  • numFmt (string) => numbering format: decimal, upperRoman, lowerRoman, upperLetter...
  • numRestart (string) => continuous, eachSect, eachPage
  • numStart (int) => starting value
  • pos (string) => sectEnd, docEnd
Exceptions

Invalid paper size.

Code samples

Example #1

The resulting Word document looks like:

Example #2

The resulting Word document looks like:

Release notes
  • phpdocx 12.0:
    • position, start, restart and format endnotes and footnotes options.
    • supported generating multiple sections with more than one column applying custom widths and spaces.
  • phpdocx 11.0:
    • space option.
  • phpdocx 9.0:
    • pageNumberType option.