Forum


Replies: 4   Views: 3464
Wordfragmant -> createparagraphstyle() possible that not work?
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 Sven May  · 06-05-2015 - 09:19

Hello! I use WordFragment class like this: $wf = new WordFragment($docx); Insert a HTML code with embedHtml method: $wf->embedHTML($htmlCode); I want to set some Word stlyes therefore I use this way: $style = array('color'=>'999999','font'=>'Arial Black'); $wf->createParagraphStyle('myStyle', $style); $wf->embedHTML('
'.$htmlCode.'
', array('strictWordStyles'=>true, 'wordStyles'=>array('
'=>'myStyle'))); Finally I got the following error message: Fatal error: Call to a member function saveXML() on a non-object in ......Classes/Phpdocx/Create/CreateDocx.inc on line 3484 If I try to use createParagraphStyle with $docx variable it's work fine but iformatting does not applying... It could be that WordFragment class not able to use this method? If yes...how can I add own word style or any word styla to my htmlCode content? Thanks!

Posted by admin  · 06-05-2015 - 10:59

Hello, The style must exist in the DOCX. So you need to add it in the main DOCX, for example with createParagraphStyle, before using it with the embedHtml method. Please test the same but without using a WordFragment. Regards.

Posted by Sven May  · 06-05-2015 - 11:23

Hi! So I did the following: $style = array('color'=>'999999','font'=>'Arial Black'); $docx->createParagraphStyle('myStyle', $style); $docx->embedHTML('
'.$htmlContent.'
', array('strictWordStyles'=>true, 'wordStyles'=>array('
'=>'myStyle'))); ...and it is not work...however where I want to use this style solution I have to use WordFragment class! Thanks

Posted by admin  · 06-05-2015 - 11:54

Hello, Please read the documentation available on: http://www.phpdocx.com/documentation/introduction/html-to-word-PHP Specifically the item Using native Word formatting with HTML. After you create the style please invoke parseStyles to check if your new style is available. Regards.

Posted by Sven May  · 06-05-2015 - 12:53

Hi! It works for me only if I make a unique word style inside the word template what I am using and make a relation to that self stlye. If I made a unique style in PHP source code added it docx with createParagraphStyle method it not works :( however the parseStyles method find it... What is important...I found a solution...so thanks for your help!