Exception 'Read wrong number of bytes from Escher record.'

Hello,
I get the following exception while trying to read the attached document:

Exception 'Read wrong number of bytes from Escher record.' occured in Aspose.Words for .NET 4.4.3.0.
For free technical support, please post this error and the file in the Aspose.Words Forums <https://forum.aspose.com/c/words/8>.

Hi
Thanks for your request. It seems that there is something wrong with your document. I can’t open it using MS Word 2003. When I tried to open attached document using MS Word 2007 I get the following error “A table in this document has been corrupted”.
The only way to make this document works is to open/save it using OpenOffice. OpenOffice show the following message during saving: “This document may contain formatting or content that cannot be saved in the Microsoft Word 97/2000/XP file format.”
So I concluded that this document is not well formatted DOC file. Which software did you use to generate this file?
Best regards.

Hello,
Actually, the corrupted document is a result of the next aspose methods execution on a correct document:

document.MailMerge.Execute(PropertySet.MergeNames, PropertySet.MergeValues)
document.MailMerge.DeleteFields()

You can find the original document in attachment to this post.
After the merge the document was opened by user’s MS Office 2007 and saved. And as a result we got the corrupted document from the first post.
BR

Hi
Thanks for additional information. Unfortunately, I can’t reproduce this on my side. I tried to use the following code.

Document doc = new Document(@"Test022\in.doc");
string[] names = doc.MailMerge.GetFieldNames();
doc.MailMerge.Execute(names, names);
doc.MailMerge.DeleteFields();
doc.Save(@"Test022\out.doc");

And then open/save the output document using MS Word 2007.
Maybe you can provide me sample application that will allow reproduce this issue. (Maybe the reason of this problem is data that you use for merging document).
Best regards.

Hello Alexey,
I finally have managed to create a simple application for the probelm detection. Actually, here are the steps to reproduce the problem:

  1. Put correct document on a network path (it is very important to put it on the network! when I open it from my local PC it works fine)
  2. Touch it with simple code:
Dim Document As Aspose.Words.Document
Document = New Aspose.Words.Document(networkpath)
Document.Save(networkpath, Aspose.Words.SaveFormat.Doc)
  1. Open in Word 2007, do any minor change (I just typed “1” at hte beggining of the document) and save the document.
    4.Touch it with simple code again. The second time I touch it I get the exception.

Best regards.

Hi
I still can’t reproduce your issue. I tried to use the following code.

Document doc = new Document(@"\\192.168.0.4\Test\in.doc");
doc.Save(@"\\192.168.0.4\Test\out.doc", SaveFormat.Doc);

Then edited the output document using Word 2007 and tried to open using AW again. It seems that all works fine on my side.
I use Aspose.Words 5.0.2.
Best regards.

Hello,
I am trying to get as much useful info as possible. I have some new information which could be useful.
I have detected that the problem occurs inly if I change the document in word 2007 from the network path after the first touch of Aspose! If I edit the document on my local PC it works fine. If I don’t touch the document with Aspose and just edit it with word 2007 it works fine as well!
Another probably useful of information. If I touch the document with Aspose and edit it by adding “1” to its beggining I have two different document sizes: if I do it from network path it is 3.766.784 bytes, if I do it form local path it is 3.765.248 bytes (I can provide both documents if you think it could help).
BR

And I am using 5.0.2!

Hi
Here is what I did.

  1. Copy input document into the shared folder.
  2. Open save document using Aspose.Words. Here is my code.
Document doc = new Document(@"\\192.168.0.4\Test\in.doc");
doc.Save(@"\\192.168.0.4\Test\out.doc", SaveFormat.Doc);
  1. Open “out.doc” from network folder using MS Word 2007 and type “1” at the beginning of document. Save document.
  2. Open changed “out.doc” using Aspose,Words.
Document doc = new Document(@"\\192.168.0.4\Test\out.doc");
doc.Save(@"\\192.168.0.4\Test\out1.doc", SaveFormat.Doc);

Document works fine at all stages. Please check maybe I have missed something. Also maybe there is something wrong with permissions on your side.
Best regards.

Hello,
Yes, you reproduced all steps in the same order as I did. But did you try it with the document attached by me?
Did you notice that opening the document with Aspose and saving it (without any changes) change size of the document? (is it normal?)
It seems that Word adds some info to the document when opens it from network folder (it can be something about permissions - that’s probably why you can’t reproduce it).

Hi
Yes, I used your file for testing.
Best regards.

Hi,

  1. Sorry for being annoying but I am still curious to know whether it is OK that Aspose changes the document size (the difference is 11 kb so it seems Aspose removes a lot of data from the document)?
  2. I’ve managed to detect the place which Aspose+Word 2007 breaks. It is th 5th page (starting from the text “Løsning i forhold til ovenstående screenshot (forsiden):”)

If I remove this page then everything works fine. And it seems that some problems occur with graphical elements as I can’t see some images in the corrupted document.
And I’d like to emphasize once more that the problem occurs only if I touch the document with Aspose!
The problem is really urgent and I am ready to provide as much info as possible to localize it.
Best regards,
Olexandr

Please find three smaller documents in attachment which give me the problem.
I hope their names are understandable.

Hi
May be there is something wrong with your office 2007. Which version do you use. I use Microsoft Office Enterprise 2007 Version 12.0.4518.1014.
Also I attached files that I get on my side. Files have same size as yours, but there is no problems to open my files.
It is very important for us to fix any problems with Aspose.Words, so please feel free to post your questions and remarks.
Best regards.

Hello,
File sizes are really equal and I can open your file - it is not corrupted. However, I can see after binary comparison that they are different. Word comparison shows that the body is equal except missing images, so there is some inner information which differs.
My Word version is 12.0.6015.5000.

Hi
I will download Service Pack 1 for MS Office 2007 and try this again. I think I will provide you information about testing tomorrow.
Best regards.