Forum


Replies: 20   Views: 11174
Greek and hebrew
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 shroom  · 18-11-2015 - 19:55

>> We recommend you to run the included examples to check if the library is working fine.

In examples/LayoutAndGeneral/importStyles/sample_1.php, the file works fine as written:
$docx->importStyles('../../files/TemplateStyles.docx', 'merge', array('crazyStyle'));

The file has the comment:
//You may also import a complete XML style sheet by
//$docx->importStyles('../files/TemplateStyles.docx', $type= 'replace');

I replaced this line:
$docx->importStyles('../../files/TemplateStyles.docx', 'merge', array('crazyStyle'));

with this:
$docx->importStyles('../../files/TemplateStyles.docx', $type= 'replace');

The styles were not imported.

>> If the styles are not being applied is because in your script or DOCX there must be something wrong: maybe mispelled styles names, wrong styles in the DOCX source...

As I noted, when I "merge" the styles from my template, they work fine, so nothing is misspelled and they are not wrong.  When I "replace" the styles, nothing is imported.

Also:
I added this line into sample_1.php just below the $docx->addText() line:
$docx->embedHTML('<p>new paragraph</p>
                  <div class="crazystyle">this is a div class="crazystyle"</div>
                  <p class="crazystyle">this is a paragraph class="crazystyle"</p>',
                 array('strictWordStyles' => true,
                       'wordStyles' => array('.crazystyle' => 'crazyStyle')
                 ));

The crazyStyle is applied to the <p class="crazystyle">, but not to <div class="crazystyle">.  This is the exact behavior I am seeing in my code.

Thanks.