PHPWord icon indicating copy to clipboard operation
PHPWord copied to clipboard

Docx file contains zero sections, unless it is saved again in MSWord

Open CharlieEtienne opened this issue 2 years ago • 3 comments

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 2023-03-19_17h43_01 2023-03-19_17h44_02
word Dir structure 2023-03-19_17h46_22 2023-03-19_17h47_24

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

CharlieEtienne avatar Mar 19 '23 16:03 CharlieEtienne

This is a sad part, I guess the developer on this package is no where to be found.

allestaire avatar Jul 04 '23 05:07 allestaire

@CharlieEtienne Hi, Could you send me a file with error, for analyzing it, please ?

Progi1984 avatar Aug 22 '24 06:08 Progi1984

Hi, here's a file generated with Articulate Storyline. test1.docx

CharlieEtienne avatar Aug 22 '24 12:08 CharlieEtienne