optimizeDocx

optimizeDocx

ADVANCED / PREMIUM TRIAL

Optimizes a DOCX.

Description
public optimizeDocx (string $source, string $target, [, array $options])

This method optimizes DOCX documents.

Parameters

source

The path to the source Word document.

target

The path to the Word document output.

options

The possible keys and values are:

Key Type Description
extraAttributes bool Remove not needed attributes in the XML files. Default as false.
imageFiles bool Optimize image files. Default as true.
imageFilesToJpegLevel int Optimize all image files transforming them to jpeg. Default as null, set quality value (70, 90...).
unusedFiles bool Remove unused files. Default as false.
xmlFiles bool Optimize XML files. Default as true.
Exceptions

Error while trying to open the (base) template as a zip file.

Code samples

Example #1

Release notes
  • phpdocx 14.0:
    • unusedFiles option.
    • removed the compressionMethod option.
    • DOCXStructure and in-memory DOCX documents.
    • return DOCXStructure.
  • phpdocx 8.5:
    • new method.