createDocxAndDownload

Generates the Word document and downloads it

PRO, PRO+ and CORPORATE PHPDocX >= 1.0

Description

public createDocxAndDownload (string $fileName)

Generates the docx file and sends it directly to the browser.

The server needs to have the corresponding MIME types for docx and docm MS Office documents: application/vnd.openxmlformats-officedocument.wordprocessingml.document and application/vnd.ms-word.document.macroEnabled.12 respectively.

Parameters

fileName

The name for the resulting Word document.

Return values

Void.

Code samples

Example #1: generates a simple docx and sends it to the browser


require_once '../../classes/CreateDocx.inc';

$docx = new CreateDocx();

$text = 'Lorem ipsum dolor sit amet.';

$docx->addText($text, $paramsText);

$docx->createDocxAndDownload('example_text');

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

Change log

  • Available since 1.0

Available examples

  • There are no additional available examples.