Forum


Replies: 1   Views: 3186
How do i set a default style for the whole embedded html?
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  · 13-02-2018 - 13:14

Hello,

A Word style only applies to an specific tag. In your code, 'myStyle' only applies to 'h1', and you can't apply a custom paragraph style to a table as you are doing, you need to set specific styles.

If you want to apply a Word style to a table, you need to create a table style. Other important point about your code, as you can read on the API page of the method (https://www.phpdocx.com/api-documentation/word-content/embed-html-Word-document-with-PHP):

strictWordStyles : If true ignores all CSS styles and uses the styles set via the wordStyles option (see next)

If this option is true, all CSS are ignored.

We recommend you to use two approaches:

· Generate a template using MS Word with all styles you want to use and then import them to the DOCX to be able to be used (https://www.phpdocx.com/api-documentation/layout-and-general/import-styles-from-a-Word-document-with-PHP).

· Use CSS to set global properties:

body {
...
}

p {
...
}

 

Regards.