Page 1 of 1

The file is corrup and cannot be opened. document.xml line 1

PostPosted: Tue Jan 28, 2014 5:20 pm
by dingo
hi,

I have a basic docx file that contains a header and footer. I have another docx that contains merge fields and a signature tag placeholder. The merge fields are replaced by doing a performMerge and the signature tag placeholder is replaced with an InlineImage. The contents of the header/footer docx are then replaced with the content from the merged docx. When I go to open the document Word complains that the file is corrupt and cannot be opened. Details point to
Location: Part: /word/document.xml, Line: 1, Column: 0

If I allow Word to recover the document it opens fine. Also if I process each docx separately they open fine. Seems to be something going screwy with replacing the content of one doc with another. I am not using mergedocx. If nothing obvious in the attached code I am wondering if mergedocx would help.

Any assistance appreciated.

WordOutput.java
code
(19.53 KiB) Downloaded 377 times


thanks,

Ralph

Re: The file is corrup and cannot be opened. document.xml li

PostPosted: Tue Jan 28, 2014 6:17 pm
by dingo
An update. When MS Word does the repair it shows a dailog saying repairs were done to "Summary Info 1".

Re: The file is corrup and cannot be opened. document.xml li

PostPosted: Wed Jan 29, 2014 3:40 pm
by dingo
Ok. A colleague of mine got to the bottom of it. The docx file I was using had a hyperlink eg http://youtube.com?... Remove the hyperlink and everything works fine. Now going to try and replace the hyperlink with a proper Word link to see if that is a work around.

So for anyone interested the attached code is a good example on how to merge fields in a Word doc and then place it as the contents between a header and footer doc. Also replaces a signature tag placeholder with an image.