PHPWord icon indicating copy to clipboard operation
PHPWord copied to clipboard

Doc to Docx conversion getting blank file

Open JBavaliya opened this issue 4 years ago • 2 comments

  • I want to read and modify existing .doc file but can't get any solution for do opration on .doc file so i am converting into .docx format by using below code

  • when we use $phpWord = \PhpOffice\PhpWord\IOFactory::load('abc.doc','MsDoc'); getting unfomated docx file.

When i am reading .doc and coverting into .docx file , file are generation but geting blank out put in docx file.

        $docPath = 'abc.doc';
        
        $phpWord = new \PhpOffice\PhpWord\PhpWord();
        $document = $phpWord->loadTemplate($docPath);
        // $document =   \PhpOffice\PhpWord\IOFactory::load('abc.doc','MsDoc'); // When we use this getting unfomated documentt

        $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord,'Word2007');
        $docxPath = 'abc.docx';
        $objWriter->save($docxPath);

JBavaliya avatar Apr 28 '21 09:04 JBavaliya

How did you convert doc to docx ?

mkq10 avatar Feb 01 '23 12:02 mkq10

@JBavaliya Hi Could you give a sample file please ?

Progi1984 avatar Aug 10 '24 13:08 Progi1984