Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert HTML code to doc using PHP and PHPWord

I am using PHPWord to load a docx template and replace tags like {test}. 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 <p>Test<b>test</b><br>test</p> to a working doc markup? I only need the basic code, no styleing. but Linebreaks have to work.

like image 449
Alexander Fuchs Avatar asked May 06 '15 12:05

Alexander Fuchs


People also ask

How do I convert HTML to PHP?

Just change file extension . html to . php (index. html to index.


1 Answers

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);
like image 192
Varun Naharia Avatar answered Sep 18 '22 21:09

Varun Naharia