optimizeTemplate

optimizeTemplate

PREMIUM TRIAL / ADVANCED

Process a DOCX to get the best performance when using the document as a template.

Description
public optimizeTemplate (string $source, string $target, array $variables = array(), string $templateSymbolStart = '$', string $templateSymbolEnd = null, bool $parseMode = false)
Parameters

source

DOCX document to be optimized.

dest

Destination path of the optimized template.

variables

Array of variables to be optimized.

templateSymbolStart

The symbol used for identifying placeholder variables within templates.

templateSymbolEnd

The symbol used for identifying placeholder variables within templates.

parseMode

If true uses the parse mode to repair and get variables. Default as false.

Exceptions

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

Code samples

Example #1:

Release notes
  • phpdocx 14.5:
    • generate a new CreateDocxFromTemplate::$regExprVariableSymbols value automatically.
  • phpdocx 14.0:
    • return DOCXStructure.
  • phpdocx 11.0:
    • DOCXStructure and in-memory DOCX documents.
    • return DOCXStructure.