PHPWord icon indicating copy to clipboard operation
PHPWord copied to clipboard

.doc file can not be read

Open liuts-plane opened this issue 2 years ago • 4 comments

Describe the Bug

I am reading a .doc file, and the code is following:

IOFactory::load($filePath, 'MsDoc')

I run it and show the error: Uninitialized string offset: 3648

otherwise: 1.the .docx file is always can be read ! 2. similar common issue i had read, but the bug is Still exists

Steps to Reproduce

Please provide a code sample that reproduces the issue.

<?php
require __DIR__ . '/vendor/autoload.php';
use PhpOffice\PhpWord\IOFactory;

$filePath = __DIR__ . '/../../../public/zzz97.doc';
$loader = IOFactory::load($filePath, 'MsDoc');

Expected Behavior

have no error

Current Behavior

Uninitialized string offset: 3648

Context

Please fill in your environment information:

  • PHP Version:7.1.33
  • PHPWord Version:0.18.3

liuts-plane avatar Mar 28 '23 07:03 liuts-plane

Convert your .doc into .docx. Since .doc is only supported by Word, you should maybe open it from there and save it as .docx.

The DOCX format was introduced with the launch of the MS Word 2007 and is still the file format up to now. PhpWord use Word2007 "logic" by default.

cavasinf avatar Jun 26 '23 09:06 cavasinf

Could you please using the unoconv to convert from .doc to .pdf

nhuttranm avatar Jun 26 '23 15:06 nhuttranm

@liuts-plane Could you send us a sample file ?

Progi1984 avatar Sep 24 '23 16:09 Progi1984

Hello,

Here is a sample test file (i renamed it.zip because .doc is not supported in the attach files feature of github) offset.doc.zip

I think that bugs #1474, #1318 and #853 are quite similar. I use the workaround https://github.com/PHPOffice/PHPWord/issues/1474#issuecomment-1302882245 and no more bug

toto975 avatar Sep 04 '24 14:09 toto975