0

Im read word file with PHPWord libary

$objReader = \PhpOffice\PhpWord\IOFactory::createReader('Word2007');
$phpWord = $objReader->load($_FILES["fileToUpload"]['tmp_name'], "UTF-8");

foreach ($phpWord->getSections() as $section) {
    $arrays = $section->getElements();
    foreach ($arrays as $e) {
        if (get_class($e) === 'PhpOffice\PhpWord\Element\TextRun') {
            foreach($e->getElements() as $text) {
                echo $text->getText();
            }
        }
    }

The problem is that i cannot detect a EOF character, i spent a lot of time to resolve this problem but didnt work at all.

1 Answers1

0

you won't get any EOF while reading with a driver

... and without a driver, you won't be able to read that format.

*.docx even contains several EOF; one per zipped XML file.


it is save to assume the the end of $phpWord->getSections() is similar to EOF.

Martin Zeitler
  • 1
  • 19
  • 155
  • 216