-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IOFactory::load destory formatting #882
Comments
Hello, i have same issue. is there some news about this issue ? |
Hello, I have the same issue |
Hey guys, I have the same issue. Formatting is lost when I IOFactory::load a file and directly save it. It also loses the images. I spend quite a few hours troubleshooting but it is leading me nowhere. I use PHPWord 0.13.0 (also tried dev-master) at PHP 7.0.4. Would be great if someone could point me in the right direction. |
I found some solutions. My problems where: 1.) losing table format, 2.) losing images. 1.) phpoffice\phpword\src\PhpWord\Reader\Word2007\AbstractPart.php line 391. That fixed losing the table borders inside a table. I also could not copy the background color of a table row. phpoffice\phpword\src\PhpWord\Reader\Word2007\AbstractPart.php line 449 expects third parameter in the array to be the attribute. 2.) Images use DrawingML ([http:https://officeopenxml.com/drwOverview.php]). That is not yet part of the phpword library. Images are now wrapped in <w:drawing>. Before it was in <w:pict>. I fixed this by adding the following code to phpoffice\phpword\src\PhpWord\Reader\Word2007\AbstractPart.php line 224.
You need to register two new XML namespaces to the xml reader. Change the following code in phpoffice\common\src\Common\XMLReader.php 92:
to
This will keep the image in your document although the styling will be lost for a part as the XMLWriter will put the image in a <w:pict> again and the reader did not extract the style yet. That is work in progress. |
Hey! I'm still having the same problem with 0.13.0 and PHP 7.1.7. I don't want to override a bunch of vendor folders because they get over written each time. |
@tjvdberg I modified the XMLReader to be able to register additional namespaces, as soon as this is released there will be no need to override the classes from Common |
@tjvdberg thanks for the fix on the table formatting. I have included your fix in the 0.14.0 release. |
@tjvdberg, thanks for sharing your code. Did you find any solution regarding image styling/formatting issue after update ( #882 (comment) )? If yes, then please share your code OR changes. Thanks in advance! |
I'm still having problems with images in the header being lost and cell border being wrong (in the original document the internal borders aren't showing, but after loading the file and saving again they are being shown)... I'm using v0.14.0... |
I'm too having a problem with this issue, I set up a docx document with a header and a footer, and some basics stylings for paragraph and headings ( as well a numbering rules or headings ) , the main idea was to open the document, and add some simple html in the first section so I can get a clean docx file ( with header, footer, and pagination and the correct styles ) . Any idea how we could fix this? Thank you |
I can not use TemplateProcessor, because i want add Section to the Dokument. |
Hi There, I have implemented a custom functionality to download my content into ".docx ." All downloaded data displaying correctly expect Table data it is skipping some columns. and also I want display "comment" in word.docx which we add the comments to text by using CKEditor. Any help please ? Actually it Should come like below image Thanks & Regards, |
@rameshsomepallidrg can you share your solution ? |
I found myself having similar issues when trying to do a combination TemplateProcessor and IOFactory::load. To get around the issue of losing formatting and images/relationships I made an extended template processor by copying various parts of PhPWord.
And this is how I use the extended template processor.
The important part is |
When i try to edit a existing word document with the IOFactory method, all formatting are destroyed after saving. Before i had table with 6 rows and 6 columns, after saving the table had 1 row with 1 big column. And the linebreaks are set random.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: