Replies: 1   Views: 912
Adddefaultstyles: where are the styles drawn from?
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 Lochspring  · 16-08-2021 - 19:13

Hi there.  We're working with PHPDocX 10, and generating our docs using the CreateDocxFromTemplate function.  I'm trying to figure out exactly where a set of styles are being drawn from when using the embedHTML or ReplaceVariableWithHTML function.

Let me start by saying I have a Heading1-6 style in my Word Template.  This, in turn, is connected to the <h1>-<h6> tags in the call to the function, as shown here:

        'stylesReplacementType' => 'mixPlaceholderStyles', 
        'useHTMLExtended'       => true,
        'isFile'                => false,
        'parseFloats'           => true,
        'embedFonts'            => true,
        'cssEntityDecode'       => true,
        'downloadImages'        => true,
        'addDefaultStyles'      => false,
        'strictWordStyles'      => false, 
        'wordStyles'            => [     
            '<h1>' => 'Heading1',
            '<h2>' => 'Heading2',
            '<h3>' => 'Heading3',
            '<h4>' => 'Heading4',
            '<h5>' => 'Heading5',
            '<h6>' => 'Heading6',
            '<table>' => 'ZimitTable',

My issue arises with addDefaultStyles.  When I set this value to "TRUE", inline styles in my HTML (say, setting color:#ff0000) are honored, and work perfectly.  However, when I do that, I am also getting a 12pt Black style being applied to all Headings and MOST Normal-styled paragraph elements.  I have removed all CSS stylesheets from the run, including the base one found in /templates/html.css. I have been unable to find where this style is being forced into the document inline.  

Please note that I can't force strictWordStyles to be true here.  I need the inline styles to function so we can override on a case by case basis.