setDefaultFont

Sets the default font for the whole Word document

PRO, PRO+ and CORPORATE PHPDocX >= 1.0

Description

public setDefaultFont (string $font)

This method sets the font that will be used by default.

This value may be overridden by methods that have the specific font option available.

Parameters

font

The name of the font: Arial, Futura, Calibri, ...

The font is not embeded within the Word document so make sure to use fonts that will be available to your target audience.

Return values

Void.

Code samples

Example #1: changes the default font to Algerian

require_once 'classes/CreateDocx.inc';

$docx = new CreateDocx();
$docx->setDefaultFont('Algerian');
$docx->addText('Lorem ipsum dolor sit amet.');
$docx->createDocx('example_font');

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

Change log

  • Available since 1.0