We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Error in merging documents

Hello,

I am using Aspose.Words version 4.2.6.0.

I am using the following method to merge the documents.

protected void AppendDocuments(Aspose.Words.Document dstDoc, Aspose.Words.Document srcDoc)
{
foreach (Section srcSection in srcDoc)
{
Node dstSection = dstDoc.ImportNode(srcSection, true, ImportFormatMode.KeepSourceFormatting);
dstDoc.AppendChild(dstSection);
}
}

Everything works fine when I try to merge documents on my local machine. When I put the same code on the production server, the code fails for some of the word documents. It works for most of the documents, but for few documents it fails. I copied the documents that were failing on the production server to my local machine and executed my code locally and it worked perfectly on my machine. But on the production server these documents are failing.

The general exception it throws on the production server is:

Error Message:The document appears to be corrupted and cannot be loaded.
at Aspose.Words.Document.x5d95f5f98c940295(Stream xcf18e5243f8d5fd3, LoadFormat xdef7b99b7fc67519, String xe8e4b5871d71a79a)
at Aspose.Words.Document..ctor(String fileName, LoadFormat loadFormat, String password)

Any help is greatly appreciated.

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

Thanks for your request. Please try using the latest version of Aspose.Words.

http://www.aspose.com/community/files/51/file-format-components/aspose.words/entry158153.aspx

Also, please attach your documents for testing.

Best regards.

I am attaching the word document that is failing on the production server. But it works locally

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

Thank you for additional information. The document works fine on my side. I use the latest version of Aspose.Words for testing. Most likely, you are using another version of Aspose.Words on server side. Therefore, the problem occurs on server environment and does not occur on development environment.

Best regards.

Thanks a lot for your help.

But I am using the same version of aspose on both my local machine and the production machine. And on production sometimes, we get the issue where the merging fails and when I try to use the same document on my machine it works fine.

Does aspose depend on any machine specific information when merging the documents?

Thanks,
Imran

Hi

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

Thanks for your request. The error occurs because Aspose.Words cannot open some document. I don’t think that the problem is dependent from your environment. Anyway, could you please tell me the differences between your development environment and the server environment (like OS version, .NET version, etc).

Also, please try using the latest version of Aspose.Words. Maybe, the problem is already fixed.

http://www.aspose.com/community/files/51/file-format-components/aspose.words/entry158153.aspx

Best regards.

DEV Environment:
OS: Microsoft Windows XP Professional
.NET Version: 2.0.50727

PRODUCTION Environment:
OS: Microsoft Windows Server 2003, Standard x64 Edition, Service Pack 2
.NET Version: 2.0.50727

I will also try to use the latest version of Aspose words and will let you know.

Thanks
Imran

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

Thank you for additional information. I tested the document on WinXP 32bit and on Win2003 32 bit. Please let me know whether the latest version works with your documents on the production environment.

Best regards.