Forum


Replies: 5   Views: 3919
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

Hello,



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: http://litesitev2.propserver7.com/watermark_issue.docx



Many thanks,



Seb



 


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

Hello,



We're checking the issue to be solved ASAP.



Regards.


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

Hello,



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



3185,3188c3185,3190

<                    $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);

>                    }



 



Regards.


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,



Seb


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

Hello,



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



Regards.