Forum


Replies: 3   Views: 1037
Upgrade to v10 break my style
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by admin  · 02-07-2020 - 12:52

Hello,

Thanks for sending the template and the code you are using. The problem is that you are using the following line:

$docx = new CreateDocx('../web/template/template.docx');

and to load a template you need to use

$docx = new CreateDocxFromTemplate('../web/template/template.docx');

This way of loading the template is the recommended one from phpdocx 4 (you can check the included samples in phpdocx 7 too). The first option of CreateDocx:

/**
     * Constructor
     *
     * @access public
     * @param string $baseTemplatePath. Optional, phpdocxBaseTemplate.docx as default
     * @param $docxTemplatePath. User custom template (preserves Word content)
     */
    public function __construct($baseTemplatePath = PHPDOCX_BASE_TEMPLATE, $docxTemplatePath = '')

is only for specific base templates (to overwrite default templates in the DOCX) and should never be used but in very specific cases. Since phpdocx 4, the way to load a template is using CreateDocxFromTemplate (otherwise you can't use template methods): https://www.phpdocx.com/documentation/practical/working-with-templates

Regards.