Appending in of Some Word Documents Resulting in Corruption of Resultant Word Doc File

There have been a number of instances of this problem where certain “input” documents are appended to an “output” document with the result that the “output” document cannot be opened by Word, with Word indicating that the output document is corrupted. Note that Word is able to open the input document. Word
A work-around was discovered where the input document is opened in Word, modified in some way, re-saved and then re-submitted to the application to be used in the generation of the output document… However, it is not practicable to use this process as a matter of routine given the nature of the user base, which is very large and globally distributed.
Few questions:

  1. Is there anything that can be done programmatically in Aspose.Word to avoid/correct issues that are somehow getting corrected by re-opening the input document and then re-saving?
  2. Are there tools that might enable me to identify the issue with the output documents that Word is not able to open…
  3. Is anyone aware of issues like this coming up where the Document being appended was created by a version of either Word 2003 or Word 2007 being used in the Far East (Japan). Note hear, though, that the documents are authored in the English language.

Hi
Thanks for your request. Could you please attach your sample document that will allow us to reproduce the problem here for testing? We will check the issue and provide you more information.
Actually, Aspose.Words does a lot of corrections when open documents. However, in your case probably there is a case that is not yet handled. So we need your document to resolve this problem.
Best regards,

There are challenges to our being able to send the document, due to legal issues. It might be possible with a confidentiality/non-disclosure agreement between my firm and Aspose. Do you know if this is something that Aspose has done in the past?
BTW, the following might also be related to this:

Error: Exception occured creating document CSU_GEN_659665087_7312_2011-11-29_09-48-32-103.docxMessage: Operation is not valid due to the current state of the object.. Stacktrace: at x4adf554d20d941a6.xb7ae55095fddecd9.x8b61531c8ea35b85()
at x4adf554d20d941a6.xc1e43d6be7c1713c.x3df13c9311a0ba9b(xb7ae55095fddecd9 x0e990edf4549ee50)
at x4adf554d20d941a6.xf8319e677a9bd732.x94b50805164237ec(x8d9303345f12a846 x31e6518f5e08db6c, x56410a8dd70087c5 x5906905c888d3d98)
at x4adf554d20d941a6.xf8319e677a9bd732.x841a9642da9aa496(x8d9303345f12a846 x31e6518f5e08db6c, x56410a8dd70087c5 x2171c110ade1f79e, x56410a8dd70087c5 x5906905c888d3d98)
at x4adf554d20d941a6.xf8319e677a9bd732.x841a9642da9aa496(x8d9303345f12a846 x31e6518f5e08db6c, x56410a8dd70087c5 x2171c110ade1f79e, x56410a8dd70087c5 x5906905c888d3d98)
at x4adf554d20d941a6.xf8319e677a9bd732.xef23aa45e7612fdd(x56410a8dd70087c5 x5906905c888d3d98)
at x4adf554d20d941a6.x61c61e304d8f82bf.x408f4b7efc86fd49()
at x4adf554d20d941a6.xeefdffd909e695da.x408f4b7efc86fd49()
at x59d6a4fc5007b7a4.xcde671c53995c411.xd9db07500873ae98(Document x3664041d21d73fdc, xdeb77ea37ad74c56 xdfde339da46db651)
at Aspose.Words.Document.UpdatePageLayout()
at DocBuilder.DocumentWriter.SaveDocument(String fileName) in C: \dev\ DocBuilder\ BLL\ DocumentWriter.cs: line 358

Hi
Thank you for additional information. Actually we do not need your real documents. We need just simple documents that will allow us to reproduce the problem. So you can simply remove sensitive information from your documents or replace it with dummy data.
Best regards,

Hre is a doc that has the problem

Hi
Thank you for additional information. But could you please also provide a simple code that will allow us to reproduce the problem. I tried open/save the document using Aspose.Words and still I can successfully open the output document using MS Word.
Also, it would be great if you attach the output corrupted document as well.
Best regards,

Here is the source and some notes. As a result of the failure, the output document does not get created.

Hi
Thank you for additional information. But it seems I still do not have enough information to reproduce the problem. In your code you pass DocumentData as a parameter. I suppose, I need these data to reproduce the problem.
Could you please create a simple application with sample data that will allow me to reproduce the problem.
Best regards,

Here is a zip containing my project files and the input files. There is a note in the zip.

A couple of things to add:

(1) I discovered that some code in the file DocumentWriter.cs that copies headers is causing issues.
(2) Also seeing the following exception

Error: Exception occured creating document CSU_GEN_999930258_6161_2011-11-15_03-42-09-726.docxMessage: Unknown color type encountered during WordML export - DrColor [EF010000]… Stacktrace: at x7c7a1dceb600404e.xd76179d16486fd56.xbe7cce711e45fa32(x26d9ecb4bdf0456d x6c50a99faab7d741, Boolean x0dae4143cd874639, Boolean xeaf65170fc9ee55f)
at x7c7a1dceb600404e.xe70e7c93110e9374.x4ac9f4b2e295bbfd(Int32 xba08ce632055a1d9, Object xbcea506a33cf9111)
at x7c7a1dceb600404e.xa25dec8c824ea182.x6210059f049f0d48(ShapeBase x5770cdefd8931aa9, Boolean xe4b4fecd3c706380, x873451caae5ad4ae xd07ce4b74c5774a7, x2cd1f1f5e07462a8 x0f7b23d1c393aed9)
at xa8550ea6ae4a81a5.xaf66e8c590b2b553.VisitShapeStart(Shape shape)
at Aspose.Words.Drawing.Shape.x2449520719b1e37e(DocumentVisitor x672ff13faf031f3d)
at Aspose.Words.CompositeNode.xf7ae36cd24e0b11c(DocumentVisitor x672ff13faf031f3d)
at Aspose.Words.Drawing.Shape.Accept(DocumentVisitor visitor)
at Aspose.Words.CompositeNode.x464d2134480a7bf2(DocumentVisitor x672ff13faf031f3d)
at Aspose.Words.CompositeNode.xf7ae36cd24e0b11c(DocumentVisitor x672ff13faf031f3d)
at Aspose.Words.Paragraph.Accept(DocumentVisitor visitor)
at Aspose.Words.CompositeNode.x464d2134480a7bf2(DocumentVisitor x672ff13faf031f3d)
at Aspose.Words.CompositeNode.xf7ae36cd24e0b11c(DocumentVisitor x672ff13faf031f3d)
at Aspose.Words.Body.Accept(DocumentVisitor visitor)
at xa8550ea6ae4a81a5.xaf66e8c590b2b553.x427772a8a25f1c7a(CompositeNode x06f7565413a01240)
at xa8550ea6ae4a81a5.x07e190e23dab42a9.xe3d2f5ee6867cec8()
at xa8550ea6ae4a81a5.x07e190e23dab42a9.DoWrite()
at xa8550ea6ae4a81a5.xaf66e8c590b2b553.x6210059f049f0d48()
at xa8550ea6ae4a81a5.xe41cdb7a2a4611b4.x8cac5adfe79bc025(x8556eed81191af11 x5ac1382edb7bf2c2)
at Aspose.Words.Document.xf381a641001e6830(Stream xcf18e5243f8d5fd3, String xafe2f3653ee64ebc, SaveOptions xc27f01f21f67608c)
at Aspose.Words.Document.Save(String fileName, SaveOptions saveOptions)
at Aspose.Words.Document.Save(String fileName)
at DocBuilder.DocumentWriter.SaveDocument(String fileName) in C: \dev\ DocBuilder\ BLL\ DocumentWriter.cs: line 359
at DocBuilder.DocumentGenerator.generateDocument(DocumentData documentData) in C:\dev\DocBuilder\BLL\DocumentGenerator.cs:line 88
at DocBuilder.Service.generateDocument(DocumentData documentData) in C: \dev\ DocBuilder\ Service.asmx.cs: line 42
DocumentGenerator.generateDocument338080930:9164fileName CSU_GEN_338080930_9164_2011-12-01_02-15-02-633.docx - Start Time: 02:15:11.8862914

Here is the scenario where the “Unknown color type encountered during WordML export” exception occurs

Hi
Thank you for additional information. however I cannot reproduce the problem on my side. I used the latest version of Aspose.Words for testing. You can download the latest version from here:
https://releases.aspose.com/words/net
Output document is generated without any issues on my side.
Best regards,

The lastest version of the library resovled the first issue I shared. There is still the second issue which I shared in a follow-up post. I have again attached this. The code is the same as previous post.
Thanks,
Bob
Here is the exception:

Error: Exception occured creating document CSU_GEN_999930035_4891_2011-12-02_11-11-33-626.docxMessage: Unknown color type encountered during WordML export - DrColor [EF010000].. Stacktrace: at x7c7a1dceb600404e.xd76179d16486fd56.xbe7cce711e45fa32(x26d9ecb4bdf0456d x6c50a99faab7d741, Boolean x0dae4143cd874639, Boolean xeaf65170fc9ee55f)
at x7c7a1dceb600404e.xe70e7c93110e9374.x4ac9f4b2e295bbfd(Int32 xba08ce632055a1d9, Object xbcea506a33cf9111)
at x7c7a1dceb600404e.xa25dec8c824ea182.x6210059f049f0d48(ShapeBase x5770cdefd8931aa9, Boolean xe4b4fecd3c706380, x873451caae5ad4ae xd07ce4b74c5774a7, x2cd1f1f5e07462a8 x0f7b23d1c393aed9)
at xa8550ea6ae4a81a5.xaf66e8c590b2b553.VisitShapeStart(Shape shape)
at Aspose.Words.Drawing.Shape.x2449520719b1e37e(DocumentVisitor x672ff13faf031f3d)
at Aspose.Words.CompositeNode.xf7ae36cd24e0b11c(DocumentVisitor x672ff13faf031f3d)
at Aspose.Words.Drawing.Shape.Accept(DocumentVisitor visitor)
at Aspose.Words.CompositeNode.x464d2134480a7bf2(DocumentVisitor x672ff13faf031f3d)
at Aspose.Words.CompositeNode.xf7ae36cd24e0b11c(DocumentVisitor x672ff13faf031f3d)
at Aspose.Words.Paragraph.Accept(DocumentVisitor visitor)
at Aspose.Words.CompositeNode.x464d2134480a7bf2(DocumentVisitor x672ff13faf031f3d)
at Aspose.Words.CompositeNode.xf7ae36cd24e0b11c(DocumentVisitor x672ff13faf031f3d)
at Aspose.Words.Body.Accept(DocumentVisitor visitor)
at xa8550ea6ae4a81a5.xaf66e8c590b2b553.x427772a8a25f1c7a(CompositeNode x06f7565413a01240)
at xa8550ea6ae4a81a5.x07e190e23dab42a9.xe3d2f5ee6867cec8()
at xa8550ea6ae4a81a5.x07e190e23dab42a9.DoWrite()
at xa8550ea6ae4a81a5.xaf66e8c590b2b553.x6210059f049f0d48()
at xa8550ea6ae4a81a5.xe41cdb7a2a4611b4.xe3d2f5ee6867cec8()
at xa8550ea6ae4a81a5.xe41cdb7a2a4611b4.x8cac5adfe79bc025(x8556eed81191af11 x5ac1382edb7bf2c2)
at Aspose.Words.Document.xf381a641001e6830(Stream xcf18e5243f8d5fd3, String xafe2f3653ee64ebc, SaveOptions xc27f01f21f67608c)
at Aspose.Words.Document.Save(String fileName, SaveOptions saveOptions)
at Aspose.Words.Document.Save(String fileName)
at DocBuilder.DocumentWriter.SaveDocument(String fileName) in c:\dev\DocBuilderEvolution\DocBuilderEvolution\DocBuilderLib\DocumentWriter.cs:line 243
at DocBuilder.DocumentGenerator.generateDocument(DocumentData documentData) in c:\dev\DocBuilderEvolution\DocBuilderEvolution\DocBuilderLib\DocumentGenerator.cs:line 93
at DocBuilderWebService.Service.generateDocument(DocumentData documentData) in c:\dev\DocBuilderEvolution\DocBuilderEvolution\DocBuilderWebService\Service.asmx.cs:line 43

Hello
Thanks for your inquiry. I still cannot reproduce the problem on my side. Could you please create simple application, which will demonstrate the problem on my side? I will check it and provide you more information.
Best regards,

I have created a very simple program that exhibits the problem (attached) and discovered that the issues does not occur if I do not set my license file, i.e. if I comment out line 35 in program.cs,

…I suspect that the error is not occuring where the license file is not provided as the library truncates output document files where there is not a license and it is likely that the part of the document with which Aspose.Word is unable to contend is not being output in this case.

Hello
Thank you for reporting this problem to us and for the additional information. I managed to reproduce the problem on my side. Your request has been linked to the appropriate issue. You will be notified as soon as it is fixed.
As a workaround you can try saving your document to DOC. As I can see the problem occurs just in case of using DOCX as output format.
Best regards,

Thanks for the help on this.
Bob.

BTW, changing our application to output .doc files rather than .docx files is problematic for us, at least in the short term. Without going into all the details how we are organized except to say that the file naming is done in a separate application, it would be extremely difficult — actually impossible — for me to get a change control for this in the near term. Also, some of the documents that are being merged into the generated documents are .docx documents. On this my intuition tells me that there may be some issues there with loss of features/fidelity when converting it to the older file format?
Thanks again,
Bob

Hello
Thanks for your request. In this case you should just wait for the fix of the original issue. At the moment this issue is pending for analysis. The responsible developer will analyze the issue and I will be able to provide you an estimate.
Best regards,