createDocx

createDocx

TRIAL / ADVANCED / PREMIUM

Generates the Word document.

Description
public createDocx ( string $fileName )

It generates a .docx or .docm file depending on how you have called the CreateDocx constructor. The constructor admits an optional parameter: the base template. If omitted the default phpdocx base template is used.

The available options are:

  • 'docx': the default base DOCX is used.
  • 'docm': uses the default Word document with m option is only recommended if you are going to macros with the addMacroFromDoc method.
  • The path to a custom base DOCX.
Parameters

fileName

The path to the resulting Word document.

Return values

DOCXStructure.

Exceptions

License not valid.

Unclosed bookmarks.

Error generating the file.

Code samples

Example #1

Release notes
  • phpdocx 7.5:
    • exception thrown when phpdocx can't create the target file.
  • phpdocx 6.5:
    • don't create temp files except when working with charts.