SOLVED PhpOffice \ PhpWord loadTemplate does not return Word properly

I have a problem displaying HTML tags when loading a template. I use HTMLtoOpenXML to render it, but in the end it's simple code. I use this:

$workDescription = $entity->getWorkDescription(); $workDescription = \HTMLtoOpenXML::getInstance()->fromHTML(str_replace("<br />","<br>", stripslashes($workDescription))); $workDescription = $this->replaceSpecialChar($workDescription); $phpWord = new \PhpOffice\PhpWord\PhpWord(); $document = $phpWord->loadTemplate($templatePath); $document->setValue('Description', $workDescription); $document->saveAs($file); 

And load the PhpWord document and set the description from the variable, but in the processed document, the result looks something like this:

 <w:p> <w:pPr> <w:pStyle w:val='OurStyle2'/> </w:pPr> <w:r> <w:t xml:space='preserve'> Test of CK Editor tags to transform them to word, </w:t> </w:r> </w:p> <w:p> <w:pPr> <w:pStyle w:val='OurStyle2'/> </w:pPr> <w:r> <w:t xml:space='preserve'> With a paragraph </w:t> </w:r> </w:p> 

If I do not use HTMLtoOpenXML, I get:

 <p>Test of CK Editor tags to transform them to word,</p> <p>With a paragraph</p> 

So it looks like I'm missing something. Any help?

+1
source share

All Articles