-
Notifications
You must be signed in to change notification settings - Fork 2.7k
phpword v0.13.1 corrupting docx file after saving #1121
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
Comments
+1 im having the same issue with |
I have the exact same problem. I load a docx file and I do NOT do ANY modifications to it. I just load it and save it again, and it gets corrupted. Original file opens in Word just fine, but after running it through PHPWord and saving it, it gets corrupted. I am hoping to get this resolved as it's affecting me. Is there any way I can help or buy you some beer for fixing it? :) |
@VickG Are you also using the TemplateProcessor? Because if not that would imply code from another part of PHPWord (like @Zxurian The string you posted does not contain any
To you also, can you share a small document to test? |
@FBnil The The original document XML is just a section that didn't have any phpword placeholders to be replaced, but you can see in the XML that phpword still modified the contents. |
I'll see if I can strip the original document back to a small section that I can share out to test with. |
I suspect
It actually matches any
Would match
With any markup in between gone...
for the tag Not sure if something like this would work:
|
@Zxurian @VickG can you edit TemplateProcessor.php function fixBrokenMacros() and edit the regexp like so:
It passes the unit tests... but will it fix your problem? |
@Zxurian @VickG I bit the bullet and rewrote the whole part, fixBrokenMacros can you test if your documents still gets corrupted after open/save with that new TemplateProcessor.php file? |
@FBnil okay, finally had some time to test this. I merged your fixBrokenMacros into 0beeb27 and tested it against the documents that were giving issues previously. Now all of them are having template variables swapped without issue. I'm sure I'm too small of a sample size, but the specific issue I was having with tags being broken/malformed is no longer happening for me. Thanks! |
Hi, is this fix going to get merged into the master? I'm having same problem processing documents via templating. |
( This was all working with v0.12, however we upgraded our server to PHP 7, and as a result, had to update phpword to v0.13. Since we use a later Zend Framework, I also had to fork and modify the phpword repo to not require specific
zendframework/zendframework: 2.4
but insteadzendframework/zendframework: ^2
)I have a .docx file that I've created that has several
${xxx}
phpword placeholders in it. With the upgrade to phpword v0.13, saving the files is now corrupting them. Trying to open the document complains of a mismatched tag (xml below), and even after correcting the mismatch, the document itself still has malformed formatting from the original.Code for template variable swapping:
Original
document.xml
Corrupted after saving
document.xml
(notice the mismatched<wps:txbx>
tag, as well as for some reason repeating and concatenating text earlier on in the xml.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: