modifyPageLayout

Modifies the Word document layout

PRO, PRO+ and CORPORATE PHPDocX >= 2.5

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 posible values are:

  • A4,
  • A3,
  • letter,
  • legal,
  • A4-landscape,
  • A3-landscape,
  • letter-landscape,
  • legal-landscape or
  • custom.

if you choose custom you should use the $options parameter.

options

The posible keys and values are:

keyTypeDescription
width int Document width in twips (twentieths of a point).
height int Document height in twips (twentieths of a point).
numberCols int Number of columns.
orient string Page orientation (portrait or landscape).
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).
gutter bool Gutter in twips (twentieths of a point). The gutter is only used for binding.

Return values

Void.

Code samples

Example #1: sets a A3 landscape layout with three columns


require_once 'classes/CreateDocx.inc';

$docx = new CreateDocx();

for($j=0; $j < 50; $j++){

	$text = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, ' .
	    'sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut ' .
	    'enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut' .
	    'aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit ' .
	    'in voluptate velit esse cillum dolore eu fugiat nulla pariatur. ' .
	    'Excepteur sint occaecat cupidatat non proident, sunt in culpa qui ' .
	    'officia deserunt mollit anim id est laborum.';

	$docx->addText($text);
}

$docx->modifyPageLayout('A3-landscape', array('numberCols' => '3'));

$docx->createDocx('example_page_layout');

The resulting Word document looks like (download .docx file):

Change log

  • Available since 2.5