Replies: 1   Views: 2989
Embedhtml with 'wordstyles' option: only apply word style, and not mix html+word
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 FGI  · 18-10-2017 - 09:14


In embedHTML(), it would be very usefull to apply ONLY Word style to elements defined in 'wordStyles' option, and NOT mix HTML + Word styles.

The result could be ugly, for example with a variable font size even if we force the size in the Word style, etc.

The 'strictWordStyles' is not an option, as it prevent all the (great) job you already made to convert everything as smooth as possible in Word (font families, etc.). And we lose the CSS formatting ("style='…'") in HTML source.

So I propose to add an option to prevent styles mixing between Word and HTML. The call function should be something like this:

$docx->embedHTML($html, [
    'strictWordStyles' => false, # we want all the great stuffs you made,
    'wordStyles' => [
        '<table>' => 'MyCustomTableStyle',
        '<h1>' => 'MyHTML_H1'
    'forceWordStyle' => true    # New option to add?


Best regards,

Posted by admin  · 19-10-2017 - 06:05


Thanks for your suggestion. We move it to the dev team.