Forum


Replies: 4   Views: 1876
Docx without phpdocx styles
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 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):

OOXMLResources::$PHPDOCXStyles = '<w:styles xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"/>';

$docx = new CreateDocxFromTemplate('document.docx');

You may need to use custom styles from your DOCX for new contents if needed (such as headings).

Regards.

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

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