Free Support Forum - aspose.com

AppendDocument Results in Corrupt Docx Output

AppendDocument Results in Corrupt Docx OutputAppendDocument:

Plesae see the attached file TestPensionDocs.zip, it contains a sample of the corrupt output docx file, all source docx files, a folder width screen captures of Word 2010 error messages and a folder with the example source code.

We are using the most current release of Aspose Word .NET

What happens is we use the AppendDocument method in a loop to create the output document, when we attempt to open the output document in Word 2010 we get an error saying:

The file TestOutPut_PensionDocument_20121121_114810.docx cannot be opened because there are problems with the contents.

When we verify TestOutPut_PensionDocument_20121121_114810.docx with Microsoft's Open XML SDL 2.0 Productivity Tool, it tells us that there are 6 errors all haveing something to do with duplicate "id" attribute values.

If we skip source document "FORM06.docx" during the AppendDocument loop, we have zero problems. BUT, we can't find anything wrong with "FORM06.docx".

So at this point we are turning to you for some expert advice on this problem.

Thanks again for your help.

Jeff Diamond

Hi Jeffrey,

Thanks for your inquiry. I have managed to reproduce the same issue at my side. I have logged this issue as WORDSNET-7343 in our issue tracking system. I have linked this forum thread to the same issue and you will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

Hi Tahir,

Any idea on what the time frame would be for a fix? Also, any suggestions for a workaround?

Thanks again for your help.

Jeff Diamond

Hi Jeffrey,


Thanks for your inquiry. Unfortunately, your issue is not resolved yet. Currently, this issue is pending for analysis and is in the queue. I am afraid, I can’t provide you any reliable estimate at the moment. Once your issue is analyzed, we will be able to provide you an estimate.

We appreciate your patience.

Hi Tahir,

Any update on the pending analysis of our issue?

Thanks again for your help.

Jeff Diamond

Hi Jeffrey,


Thanks for your inquiry. Unfortunately, there is no further news about this issue; this issue is still pending for analysis and is in the queue. We will inform you as soon as this issue is resolved. We apologize for any inconvenience.

Best regards,

The issues you have found earlier (filed as WORDSNET-7343) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

Thanks for the update (Aspose Words 11.11.0), I just tested this and it does not solve the problem at all. I simply updated Aspose Words on my PC, and reran the previously attached test code and documents, verifying that the test code is running Aspose Words 11.11.0. The output document cannot be opened by Word.

Please rerun the test scenario I provided. I believe that you will get the same bad results.

Thanks again for your help.

Jeff Diamond

Hi Jeffrey,


Please accept my apologies for your inconvenience.

Thanks for your inquiry. Unfortunately, your issue is not resolved yet. I have asked for the detail of this issue from our development team. As soon as, any information is shared by them, I will be more than happy to share that with you.

Thanks for your patience.

I am having the same issue as Jeff, which was not solved by the .NET update (I am already utilizing 11.11.0). I am anxious for a fix. Please let us know if there is a workaround in the interim, such as using an older version.

Thanks for your assistance,
Jason

Susquehanna Bank,

Have a look at the work-around below. Basically after loaded the word 2010 docx file into an Aspose document I save it to a memory stream in "DOC" format, then load it back into an Aspose document in "DOC" format, then append, then save the compound document back to the disk as "DOCX". This does add a some overhead, but I needed something that worked while I wait for the good people at Aspose to fix their code.

BTW: I have not observed any loss of formatting due to the work-around, but you probably want to look out for that kind of thing.

Best of Luck!

J Diamond


'theCalcResults is a list loaded with source document filenames
'source documents are in docx ( word 2010 ) format

Dim tdoc As New Document
tdoc.RemoveAllChildren()

For i As Integer = 0 To theCalcResults.CalcDoucuments.Count - 1

Dim srcDoc As New Document(PensionDocumentsPath & theCalcResults.CalcDoucuments(i).DocumentName)

'******************************************************************
'temp workaround for duplicate "id" attribute values in graphical elements
'causing corrupt output docx file
'workaround is, save document to stream in old style "Doc" format
'before appending to output document
Dim TmpStream As New MemoryStream
srcDoc.Save(TmpStream, SaveFormat.Doc)
Dim TmpLoadOptions As New LoadOptions
TmpLoadOptions.LoadFormat = LoadFormat.Doc
srcDoc = New AsposeWordsDoc(TmpStream, TmpLoadOptions)
'******************************************************************

tdoc.AppendDocument(srcDoc, ImportFormatMode.KeepSourceFormatting)

Next i

'save.... ( in docx format (word 2010 ) )
Dim strTargetDirectory As String = PensionDocumentsPath
Dim strFilePrefix As String = "TestOutPut_PensionDocument"
Dim strFileName As String = strFilePrefix & "_" & Format$(Now, "yyyyMMdd_HHmmss")
strFileName = strFileName & ".docx"
Dim tSaveOpt As New OoxmlSaveOptions(SaveFormat.Docx)
tSaveOpt.Compliance = OoxmlCompliance.Iso29500_2008_Transitional
tdoc.Save(strTargetDirectory & strFileName, tSaveOpt)v

Hi Jeffrey/Jason,

Please accept my apologies for your inconvenience.

Unfortunately, this issue is not resolved yet. However, we have logged this issue as WORDSNET-7613 in our issue tracking system. Hopefully, this issue will be fixed in next release of Aspose.Words.

Thanks for your patience.

Jeff,

I've implemented the fix you suggested and it worked flawlessly. Thanks so much for taking the time to post it, I really appreciate it! My next move was going to be to save all the source .docx documents as .doc, but this is a much better option.

It should be noted, while I also received "The file cannot be opened because there are problems with the contents" error, analysis with the Microsoft's Open XML SDL 2.0 Productivity Tool indicated my issue was "The attribute 'id' has invalid value '-456211936'. The string '-456211936' is not a valid 'UInt32' value." So Jeff's solution works with a number of "id" related problems in the compound document.

A function to save the Aspose DOCX document as an Aspose DOC document as Jeff suggested, written in C#:

// Temporary workaround for corruption resulting from appending .docx

// files when no source .docx files are corrupt (bit.ly/WIPKXC)

protected Document GetWordDocumentDocxInDocFormat(Document dWordDocx) {

LoadOptions optsLoadWordDoc = new LoadOptions();
optsLoadWordDoc.LoadFormat =
LoadFormat.Doc;

using (MemoryStream mTempStream = new MemoryStream()) {

dWordDocx.Save(mTempStream, SaveFormat.Doc);

return new Document(mTempStream, optsLoadWordDoc);

}
}

Thanks again!
Jason

Hi Jason,

It is nice to hear from you that your problem has been solved after using workaround shared by Jeff. We always appreciate positive feedback from our customers. We will update you via this forum thread once the issue is resolved.

Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.

Thanks for your patience.

I am having the same issue. I will try implementing the work around but it definitely slows the system down with the extra saves.

The workaround worked for me too.

Hi,


Thanks for your patience. We have a good news for you that is WORDSNET-7613 has now been resolved and its fix will be included in the next version of Aspose.Words (v13.1.0) which is planned to be released by the end of this month (around January’ 31, 2013). We will inform you via this forum thread as soon as the new release is published at the end of the month.

Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.

The issues you have found earlier (filed as WORDSNET-7613) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

I have installed 13.1 and am still having the issue. The workaround does work for me. My project files and source documents are attached.

The "choose file" button in Rockmelt does not work by the way in the attachment upload dialog.

Just for the record, I’m the original poster on this thread and the fix appears to be working just fine for me.