PHPWord
PHPWord copied to clipboard
Docx file contains zero sections, unless it is saved again in MSWord
Describe the Bug
A software I use generates Word files (.docx). I can open them in MS Word without problem. If I try to read them with PHPWord, it appears to be empty. But if I open the file in MS Word and save it, the file is readable by PHPWord.
There are some differences before and after saving the file:
| Before | After | |
|---|---|---|
| Filesize | 14Ko | 50 Ko |
| Root Dir structure | ![]() |
![]() |
word Dir structure |
![]() |
![]() |
Steps to Reproduce
Please provide a code sample that reproduces the issue.
<?php
require __DIR__ . '/vendor/autoload.php';
$phpWord = IOFactory::load('document.docx');
$sections = $phpWord->getSections();
var_dump($sections);
// Here, $sections is an empty array.
// If I open, save the file, and test it again, I got a lot of sections
Context
- PHP Version: 8.1
- PHPWord Version: 1.0.0
This is a sad part, I guess the developer on this package is no where to be found.
@CharlieEtienne Hi, Could you send me a file with error, for analyzing it, please ?
Hi, here's a file generated with Articulate Storyline. test1.docx



