PHPWord
PHPWord copied to clipboard
Doc to Docx conversion getting blank file
-
I want to read and modify existing
.docfile but can't get any solution for do opration on.docfile so i am converting into.docxformat by using below code -
when we use
$phpWord = \PhpOffice\PhpWord\IOFactory::load('abc.doc','MsDoc');getting unfomateddocxfile.
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);
How did you convert doc to docx ?
@JBavaliya Hi Could you give a sample file please ?