From 354b6620590ba355981e907df85ec9e24fef6675 Mon Sep 17 00:00:00 2001 From: LMR <59361885@qq.com> Date: Fri, 4 Jan 2019 17:03:49 +0800 Subject: [PATCH] deal with docx --- .gitignore | 1 + application/controllers/info_amp.php | 8 +++++++- application/libraries/wordphp.php | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 6d4da9fd..a63c10d0 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ /kcfinder/cache/* */cache/* /author/document/* +/application/libraries/composer diff --git a/application/controllers/info_amp.php b/application/controllers/info_amp.php index f5eb514d..6bfd4ecf 100644 --- a/application/controllers/info_amp.php +++ b/application/controllers/info_amp.php @@ -382,6 +382,7 @@ class Info_amp extends CI_Controller } $md5_name = $md5_file.$ext; $path = realpath('../cht-system/views/information/word_source').'/'.basename($md5_name); + $html = realpath(APPPATH.'/libraries/composer/vendor/'); if (move_uploaded_file($file['tmp_name'], $path)) { $this->load->library('wordphp'); $rt = new WordPHP(); @@ -389,7 +390,12 @@ class Info_amp extends CI_Controller $rt->img_prex = $md5_file; $html = $rt->readDocument($path); $html = str_ireplace($rt->img_dir, '//202.103.68.62:9096/information-view/information/word_img', $html); - //file_put_contents($path.'.txt', $html); + /*//phpWord转HTML + require_once($html.'/autoload.php'); + $phpWord = \PhpOffice\PhpWord\IOFactory::load($path); + $xmlWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, "HTML"); + $xmlWriter->save($path.'.html'); + */ echo(json_encode(array( 'status' => 'success', 'path' => $path, diff --git a/application/libraries/wordphp.php b/application/libraries/wordphp.php index e07e0f0b..1e517311 100644 --- a/application/libraries/wordphp.php +++ b/application/libraries/wordphp.php @@ -485,7 +485,7 @@ class WordPHP // look for new paragraphs $paragraph = new XMLReader; $p = $reader->readOuterXML(); - //return $p; + return $p; if ($reader->nodeType == XMLREADER::ELEMENT && $reader->name === 'w:p') { // set up new instance of XMLReader for parsing paragraph independantly