Change the base template and its default styles

phpdocx uses a base template with default styles. The library uses them when the user doesn’t indicate explicit values, e.g., default sizes for paragraphs and headings.

You can modify these initial values easily with the parameters available for each method of the API or using the setDocumentDefaultStyles method. However, you can change them too with a base template of your own by instantiating the class CreateDocx.

The following code defines a custom base template:

Using the CreateDocxFromTemplate class, default styles are added to the DOCX. These default styles are used when adding specific contents such as headings or comments. To avoid adding these default styles in all cases, the $PHPDOCXStyles public static variable can be customized, for example setting empty default styles:

This static variable must be set before instantiating objects with CreateDocx and CreateDocxFromTemplate classes.