Save to stream as FormatAsposePdf throws exception

When I save my manipulated word file to a disk file and then reopen it as an aspose.words document and save to a file as FormatAsposePdf, I get no problems. I'm now trying to speed things up by streaming the intermediate results with the following errors:

If I save the doc to a stream as FormatAsposePdf, then I get I a null reference exception.

If I save to a stream in FormatDocument, then try to reopen that stream as a document, so I can save it to a stream as FormatAsposePdf, I get an Unknown file format exception.

I can't reproduce this in a small example so I'm attaching a rather large piece of code to demonstrate the problem. You can reproduce the problem by running main() and the exception will be thrown in in the method ConvertToPdf(). There are 2 versions of this method that return a stream, that correspond to the 2 problem instances listed above. They can be called un/commenting marked code in the method Run()

I'm using aspose.words version 3.5.0.0.

Can you please take a look?

Charu Tevari

Thank you for reporting this problem to us.

I can see that you have the temporary workaround for this problem. I have logged this issue to our database as Issue #854. We will research it in 1-2 weeks and let you know.

When you save and reopen via MemoryStream don’t forget to reposition the MemoryStream pointer by MemoryStream.Seek(0, SeekOrigin.Begin). Otherwise, you will probably get ‘Unknown file format’ exception.

Thanks. That was indeed the problem in case 2 where I was getting 'Unknown file format' exception.

I eagerly await the resolution of the null reference exception.

-Charu Tevari

Fixed in Aspose.Words 3.6 which is now available for download.