addFooter

Inserts footers into the Word document.

PRO, PRO+ and CORPORATE PHPDocX >= 1.0

Description

public addFooter ( array $footers)

This method allows for the insertion of a set of footers into the Word document.

Since version 3.0 it is posible to include a different footers for:

  • the first page or title page,
  • even pages and
  • odd pages (this one is the default footer for the whole document if no different footers are defined for the first or even pages).

The contents of the different footers are defined via the use of WordML fragments. These footer WordML fragments allow for the insertion of:

  • text paragraphs,
  • current date and/or hour,
  • images,
  • links,
  • lists,
  • page numbers,
  • shapes,
  • tables
  • and HTML content.

You may also import the footers of an existing docx document via the ImportHeadersAndFooters method.

Parameters

footers

An array with the different footer contents.

The posible keys and values are (required options are shown with yellow background):

keyTypeDescription
default WordMLFragment The WordML fragment object containing the contents for the default (odd pages) footer
even WordMLFragment The WordML fragment object containing the contents for the even pages footer
first WordMLFragment The WordML fragment object containing the contents for the first (title) page footer

Return values

Void.

Code samples

Example #1: inserts a default footer into a docx.

require_once 'classes/CreateDocx.inc';

$docx = new CreateDocx();

$footerImage = $docx->addImage(array('name' => '../files/img/image.png', 'dpi' => 300, 'rawWordML' => true, 'target' => 'defaultFooter'));
$myImage = $docx->createWordMLFragment(array($footerImage));

$docx->addFooter(array('default' => $myImage));

$docx->createDocx('example_footer');
                    

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

Change log

  • Available since 1.0
  • Insertion of arbitrarily complex Word content included in 3.0
  • Optional different headers for first, even and odd pages available since 3.0

Available examples