This project is read-only.

Insert docx rendered to template docx

Jul 9, 2012 at 1:28 PM
Edited Jul 9, 2012 at 3:01 PM


I would like to use the same function than with values : $document->setValue($search,$replace);

with my html converted to docx.

I need just to replace the $search by my html code. I don't need to create a new file and in fact if i create a new one, i don't know how to insert the content in the other file.


How can i do ?



Nov 26, 2012 at 11:54 PM

hi, i've had the same problem and created a simple php function :

use it to convert your html to openxml, then you can use the setValue function.

Feel free to add content to it, for now it can only do some HTML styles (bold, italic, underlined, and bullet lists)

i will add more with time

Nov 30, 2012 at 1:05 PM

did you try on a template ?


your script makes errors.


In fact to insert an html formatted text, you would to have to up to precedent <w:p> so setValue can't work.

Nov 30, 2012 at 2:57 PM

it works for the template i'm using.

What errors do you have ?


(i used my own styles "<w:pStyle w:val='BulletStyle'/>" to format the text i put into the docx document)