Word Master Files cannot be converted

Hi Aspose Support Team,
I’m using Aspose Word 13.5.0.0 in a SharePoint 2010 solution. I want to convert a MS Word Master file into a merged Word file and then via Aspose PDF into a PDF/A.
Converting standard Word files works fine (I’ve converted already hundreds of files). But if I use a Master file (see example in attachments) I get an error (see screenshot in attachment).
Thx for your support

Hi Thomas,

Thanks for your inquiry.

After an initial test with Aspose.Words 13.6.0, I was unable to reproduce this exception on my side. I can load all of your Word documents into Aspose.Words’ DOM on my side. Please upgrade to the latest version of Aspose.Words from the following link:
https://releases.aspose.com/words/net

I hope, this helps.

Best regards,

Thx for your reply.
I got the same exception again. I’ve added the SharePoint Log as attachment.
Would you please poste the code that you have used.
Thank you

Hi Thomas,

Thanks for your inquiry. I tried loading all of your documents one by one into Aspose.Words’ DOM and did not manage to replicate this exception on my side. Please create a simple application (for example a Console Application Project) that helps me reproduce the same problem on my end and attach it here for testing. As soon as you send this application to me, I’ll start investigation into your issue.

Best regards,

Hi, I’ve created a console application (see code.txt).
If I use:
StreamReader stream = new StreamReader(path);
Aspose.Words.Document documentWord = new Aspose.Words.Document(stream);
I get an exception. If I use
Aspose.Words.Document documentWord = new Aspose.Words.Document(stringPath);
it works.
But Aspose.Words does not merge the documents. How can I merge all documents into one?

Hi Thomas,

Thanks for the additional information and sorry for the delayed response.

*Thomas:
If I use:
StreamReader stream = new StreamReader(path);
Aspose.Words.Document documentWord = new Aspose.Words.Document(stream);

I get an exception. If I use
Aspose.Words.Document documentWord = new Aspose.Words.Document(stringPath);
it works.*

Please note that the document you’re trying to read must be stored at the beginning of the stream i.e. Aspose.Words tries to read from the current position of stream and in case it has nothing to read, it throws FileCorruptedException. Please ensure to rewind the stream position back to zero (before closing the stream) as follows so that it is ready for AsposeWords.

stream.Position = 0;

Thomas:
But Aspose.Words does not merge the documents. How can I merge all documents into one?

Please refer to the following sections of the documentation which outline everything you need to know about appending/merging documents in Aspose.Words
https://docs.aspose.com/words/net/insert-and-append-documents/

Please let me know if I can be of any further assistance.

Best regards,

*awais.hafeez:
Please ensure to rewind the stream position back to zero (before closing the stream) as follows so that it is ready for AsposeWords.

stream.Position = 0;
Hi,
the exception occurs in line
Aspose.Words.Document documentWord = new Aspose.Words.Document(stream);
According to your last post and the documentation (https://docs.aspose.com/words/net/save-a-document/) I have to set the stream position to zero before closing. But the error occurs already on opening.*

Hi Thomas,

Thanks for the additional information. Unfortunately, I was still unable to reproduce this exception on my side. Could you please also double check if you’ve attached the correct document you’re getting this problem with? It would be great if you please create a standalone/runnable simple application (for example a Console Application Project) that helps me reproduce the same problem on my end and attach it here for testing. As soon as you get this application ready for me, I’ll start investigation into your issue. Thanks for your cooperation.

Best regards,