Forum


Replies: 4   Views: 72
Docx without phpdocx styles

Posted by pwctechnicalsecurity  · 19-10-2019 - 22:21

After I have succesfully created my $docx from a base template..

$docx = new CreateDocxFromTemplate($this->path);

and render it later..

$docx->createDocx('docs/example.docx');

I get a Word file that includes both the styles I defined in my base template, but it also holds PHPDocX's own styles (including Title PHPDOCX). How do I prevent these PHPDocX styles to be included in the resulting file? - we are using the Premium version.

Posted by pwctechnicalsecurity  · 20-10-2019 - 10:38

Hello,

Thanks for your swift response. I must be overlooking something. To me, the only difference is that I used CreateDocxFromTemplate(#linktobase) and the referred snippet uses CreateDocx(#linktobase). However, if I am using CreateDocx, I only get the PHPDocX styles and none of my own styles. With CreateDocxFromTemplate it is a combination of my own styles together with PhpDocx defaults.

What am I overlooking? Any thoughts?

Regards.

Posted by admin  · 20-10-2019 - 16:53

Hello,

phpdocx uses internal styles to be able to add new contents correctly. These styles are set in the base template (templates/phpdocxBaseTemplate.docx in Basic, Advanced and Premium licenses) and in the DOCXStructureTemplate.php file in the Premium license.

When using a custom template, some styles are imported. These default styles are available in OOXMLResources.php, $defaultPHPDOCXStyles variable. This is a static public variable so you can overwrite to set the styles to be imported (for example a set of them or none of them). Please note that there's no option to avoid adding all styles used by phpdocx, so you may need to use custom styles for new content added if needed.

Regards.

Posted by pwctechnicalsecurity  · 21-10-2019 - 17:46

Deleted by pwctechnicalsecurity · 21-10-2019 - 19:19