Replies: 5   Views: 3768
Watermark causes corruption
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 seb  · 25-09-2013 - 12:41


If adding a watermark to a document that was originally created by PHPDOCX, then the resulting Word file is claimed to be corrupt my MS Word when you try and open it.

The error message upon opening is "The file MyFile.docx cannot be opened because there are problems with the contents."

However you can click OK and it then allows you to 'recover' the document and it opens but with some slight image/text alignment issues.

Is there a fix for this issue? Here is the document that I've generated with the problem:

Many thanks,



Posted by jorgelj  · 26-09-2013 - 09:10


We're checking the issue to be solved ASAP.


Posted by jorgelj  · 26-09-2013 - 13:42


Please apply this diff to check if the issue is solved:


<                    $default = '<Default Extension="' . $extension . '" ContentType="image/' . $extension . '" />';

<                    $ctFragment = $this->_watermarkDocxContentTypesDOM->createDocumentFragment();

<                    $ctFragment->appendXML($default);

<                    $this->_watermarkDocxContentTypesDOM->documentElement->appendChild($ctFragment);


>                    if(strpos($this->_watermarkDocxContentTypesXML, 'Extension="' . $extension . '"' ) === false){

>                         $default = '<Default Extension="' . $extension . '" ContentType="image/' . $extension . '" />';

>                         $ctFragment = $this->_watermarkDocxContentTypesDOM->createDocumentFragment();

>                         $ctFragment->appendXML($default);

>                         $this->_watermarkDocxContentTypesDOM->documentElement->appendChild($ctFragment);

>                    }



Posted by seb  · 26-09-2013 - 17:15

Thanks for the patch - this now works, but it's vertical alignment seems not to be centered.

Would it be possible to align the watermark in the true center of the page?

Thank you,


Posted by jorgelj  · 27-09-2013 - 08:11


There's no way to center a background image in Word but scaling it to page size.