Forum


Replies: 2   Views: 1415
Exception on importstyles() with version 10.0, works in 9.5
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by dan_brokerbusiness  · 10-09-2020 - 01:01

Hi

we are getting the exception "DOMDocument::loadXML(): Empty string supplied as input" (see https://ibb.co/2tySFhG) when using importStyles with 'replace' as second parameter and even the most simple word document (newly created MS Word with only 1 Word and a style applied). 

It works when the 'merge' param is used instead of 'replace'.
It works when using phpdocx version 9.5, but fails in 10.0.

$docx = new CreateDocx();
$docx->importStyles(resource_path('word/simple.docx'), 'replace');
$docx->createDocx('Output');

Seems to be a bug?

Regards

Posted by admin  · 10-09-2020 - 06:54

Hello,

You are right, there was a minor bug in the importStyles method. All phpdocx 10 packages (Basic, Advanced and Premium) has been fixed with the correction. If you don't want to download the new package, please edit CreateDocx.php (classes folder in the classic package or Classes/Phpdocx/Create in the namespaces package), and in the importStyles method replace the following line:

$this->_wordStylesT->loadXML($zipStyles->getContent('word/numbering.xml'));

with:

$this->_wordStylesT->loadXML($zipStyles->getContent('word/styles.xml'));

We apologise for any inconvenience caused

Regards.

Posted by dan_brokerbusiness  · 11-09-2020 - 04:02

After downloading the updated package its working now. Thanks!