How can I convert a docx document to html using php? -



How can I convert a docx document to html using php? -

i want able upload ms word document , export page in site.

is there way accomplish this?

//function :: read docx file , homecoming string function readdocx($filepath) { // create new zip archive $zip = new ziparchive; $datafile = 'word/document.xml'; // open received archive file if (true === $zip->open($filepath)) { // if done, search info file in archive if (($index = $zip->locatename($datafile)) !== false) { // if found, read string $data = $zip->getfromindex($index); // close archive file $zip->close(); // load xml string // skip errors , warnings $xml = domdocument::loadxml($data, libxml_noent | libxml_xinclude | libxml_noerror | libxml_nowarning); // homecoming info without xml formatting tags $contents = explode('\n',strip_tags($xml->savexml())); $text = ''; foreach($contents $i=>$content) { $text .= $contents[$i]; } homecoming $text; } $zip->close(); } // in case of failure homecoming empty string homecoming ""; }

ziparchive , domdocument both within php don't need install/include/require additional libraries.

php html docx

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -