Forum


Replies: 3   Views: 3211
How do i deal with html in a word fragment please
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 maxelcat  · 16-10-2017 - 15:07

Thank you for your reply. I have used check.php - tidy is showing green. I have made some progress but there is still something not right (I think)

Here is some of my code showing how I produce the document

foreach ($tabledata as $value){
                                $titlewf->addtext($value['SUBJECT'].' '.$value['GRADE'],
                                                                 
                                                                 array('bold'=>'true',
                                                                          'color'=>'2e74b5',
                                                                           'font'=>'Arial',
                                                                           'fontSize'=>'12'
                                                                          )
                                                                 
                                                                 );
                                $DESCRIPTION = $value['DESCRIPTION'];
                                $titlewf->embedHTML('<div>'.$DESCRIPTION.'</div>');      
                        } //foreach
                        
                        
                        $docx->replaceVariableByWordFragment(array(
                                'SUBJECT' => $titlewf, 
                                'GRADE'=>$titlewf
                        
                        ), array('type' => 'block'));
                        
                        
                        
                        $docx->createDocx('../wordreports/fullreport/'.$filename);
                

I have managed to get the html code to embed - so that's great.

However, I noticed that I have to wrap the $DESCRITPION in <div> tags (as you can see - <p> tags work too). If I don't, then no word documents are produced, though no error code shows.

I checked in the database where the descriptions are located - and the are wrapped in well formed html.

Somethign doesn't 'feel' right to me.

Am I doing something wrong?

Thanks in advance