Alexander Fuchs Alexander Fuchs - 8 months ago 234
HTML Question

Convert HTML code to doc using PHP and PHPWord

I am using PHPWord to load a docx template and replace tags like

. This is working perfectly fine.

But I want to replace a value with html code. Directly replacing it into the template is not possible. There is now way to do this using PHPWord, as far as I know.

I looked at htmltodocx. But it seams it will not work either, is it posible to transform a peace of code like
to a working doc markup? I only need the basic code, no styleing. but Linebreaks have to work.


Here is the link to the github. It is working fine Html-Docx-js.

And it is the demo also available here.

Other option is this Link.

 $toOpenXML = HTMLtoOpenXML::getInstance()->fromHTML("<p>te<b>s</b>t</p>");
    $templateProcessor->setValue('test', $toOpenXML);