I've been successfully able to generate a .docx
document with https://github.com/djpate/docxgen but as soon as i try to include TinyMCE text, i no longer can open the document. (non valid char).
Is there a way to convert the HTML text before giving it to docxgen to avoid such error?
Finally, I settled with this answer to create a doc (simply output html and Word will recognize it):
header( 'Content-Type: application/msword' );
header("Content-disposition: attachment; filename=" .date("Y-m-d").".doc");
/*
header("Content-type: application/vnd.ms-word");
header("Content-disposition: attachment; filename=" .date("Y-m-d").".rtf");
*/
$html = preg_replace('%/[^\\s]+\\.(jpg|jpeg|png|gif)%i', 'http://www.akubocrm.com\\0', $html);
print "<html xmlns:v=\"urn:schemas-microsoft-com:vml\"";
print "xmlns:o=\"urn:schemas-microsoft-com:office:office\"";
print "xmlns:w=\"urn:schemas-microsoft-com:office:word\"";
print "xmlns=\"http://www.w3.org/TR/REC-html40\">";
print "<xml>
<w:WordDocument>
<w:View>Print</w:View>
<w:DoNotHyphenateCaps/>
<w:PunctuationKerning/>
<w:DrawingGridHorizontalSpacing>9.35 pt</w:DrawingGridHorizontalSpacing>
<w:DrawingGridVerticalSpacing>9.35 pt</w:DrawingGridVerticalSpacing>
</w:WordDocument>
</xml>
";
die($html);
I've decided to go with the pro version of the library http://www.phpdocx.com/ as it simplifies the whole process. I hope it'll fill my needs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With