Free Support Forum - aspose.com

Doc Template to Docx File -> Word reports problem with contents

Hi

I am filling up the merge fields of a Word Doc (old file format) document and creating a Word Docx document. Word reports me the following errors. When i save the document to doc, i dont get the error.

When I open the document i get the error:
The file Document.docx cannot be opend because there are problems with the contents.

After that i get the message:
Word found unreadable content in Document.docx. Do you want to recover the contents of this document?..

When I click ok, I get the expected document.

This error aperars with serval templates.
Can you help me?

Attached the template and the output document.

Thanks
Adrian

For saving the document i use:
mergedDocument.Save(response, “test.docx”, ContentDisposition.Attachment, null);

I’m using the last version of aspose.words (9.4).

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. You should just add Response.End() and shown below:

mergedDocument.Save(Response, "test.docx", ContentDisposition.Attachment, null);

Response.End();

Hope this helps.

Best regards.

Hi

Thanks for your quick response. But this does’t solve my problem. I get the same document.

Any other idea?

Thanks
Adrian

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. Could you please attach your output document after adding Response.End(). I will check it and provide you more information.

Best regards,

Attached the Document in docx and doc (to show there is no problem) with response.end.

Thanks
Adrian

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. There is still some problem with package. As you may know DOCX is zip archive with XML content inside. If you unzip your DOCX and zip it again, there is no problem. But this is just low level reason of the problem. We need to find out why this occurs with your document. So, could you please create a simple application, which will allow me to reproduce the problem on my side? I will check your code and provide you more information.

Best regards,

Hi

Now i get the problem. When i use Response.End(); i get a System.Threading.ThreadAbortException. ErrorMessage: Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.

If I catch that message I doen’t have any problems with docx.
Any idea how to solve that?

Thanks
Adrian

Hi Adrian,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. It is difficult to suggest you something without your code. Please create a simple application that will allow me to reproduce the problem. I will investigate the problem and provide you more information.

Best regards.

Hi Alexey

I tried to reproduce the problem in a simple application, but I don’t get that error. My code is kind of complex and its not easy to make a working example out of it.

I think I have to live with that error. Thanks for your support!

Adrian

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. I suppose, in your case, you are trying to achieve downloading process without full PostBack (like Ajax). If so, maybe you can try using one of approaches suggested here:

http://www.aspose.com/demos/.net-components/aspose.words/csharp/ajax/default.aspx

Best regards,