D
D
Dmitry2016-06-15 23:42:08
Yii
Dmitry, 2016-06-15 23:42:08

How to read .doc file in PhpOffice/PhpWord?

Good evening.
There was a problem reading the .doc file with PhpOffice
Code:

$objReader = IOFactory::createReader('MsDoc');

$phpDoc = $objReader->load($path.'/2.doc');

foreach ($phpDoc->getSections() as $sections) {
  $arrsec = $sections->getElements(); 

    foreach ($arrsec as $el) {
         if($el instanceof Text){
               $body .= $el->getText();
    	 }
    }
}

As a result, the browser displays the following:
d4d659221bf2441094b0a07ca4d030a4.png
At the same time, if you "read" other files (.docx, odt), with the appropriate settings, the contents of the files are displayed more or less acceptable.
How can this problem be solved?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrew, 2016-06-16
@slo_nik

If you do not need a link to a specific library, then there is an excellent article on this topic on Habré https://habrahabr.ru/post/72745/
I may be wrong about this library, specifically PhpOffice / PhpWord does not work with the * .doc format , *.docx only

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question