Free Support Forum - aspose.com

Document.Save(stream- saveoptions) notsupportedexception

Hi,


I recently changed the aspose version in an existing application from v9.0 to v10.0. After fixing all build errors resulting from this change I still have a runtime error when calling Document.Save like this:

Public Overrides Sub Draw(ByVal stream As System.IO.Stream)
	_myDocument.Save(stream, New Aspose.Words.Saving.PdfSaveOptions())
End Sub
This results in a Notsupported exception.
When I replace the stream by a filepath the pdf is successfully created with correct content. Any idea how to fix this?
GReetings,
ruben

Hello

Thanks for your request. I cannot reproduce the problem on my side using the latest version of Aspose.Words for .NET (10.5.0). Please see the following link:

http://www.aspose.com/documentation/.net-components/aspose.words-for-.net/aspose.words.document.save_overload_5.html

Also, could you please create simple application which will allow me to reproduce the problem on my side?

Best regards,

Hi,


Included is a small project that reproduces the problem. Just insert a random word document and you will see the problem.
By the way, I also tried this using
doc.Save(Me.Response.OutputStream, New Aspose.Words.Saving.PdfSaveOptions())
with the same result.
Greetings,

Ruben

Hello

Thank you for additional information. In this case you should use the following Save overload:

http://www.aspose.com/documentation/.net-components/aspose.words-for-.net/aspose.words.document.save_overload_6.html

// Send the document in Word format to the client browser with an option to save to disk or open inside the current browser.

doc.Save(Response, "MailMerge.ExecuteArray Out.doc", ContentDisposition.Inline, null);

Also, please note: System.Web is not available in the .NET Framework 3.5/4.0 Client Profile, that is why Document.Save overloads which allows you to save to a System.Web.HttpResponse object is not available. In your case, you should use Aspose.Words for .NET 2.0 in your ASP net application.

Best regards,

Hi,


Thanks for the help, but I can not use that Save overload in my project. There is a web page calling a method in a seperate class to generate a report using aspose and send this to the browser. This webpage gives the Response.outputstream as an argument so that the class can use this stream to send the file to the browser. I can not change this as this is an existing application which originally did not use aspose, but an other reporting library, and this old system has to continue working for legacy reports.

I still do not understand why I’m getting a ‘notsupportedexception’ in my project (and the example project). Is there no way to get this to work?

Greetings,

Ruben

Hi Ruben,

Thanks for your request. in this case, I think, you should save the document into a newly created stream and then write content of this stream to your response. Code should look like the following:

// Create a stream and save docuemnt into it.

using (MemoryStream ms = new MemoryStream())

{

doc.Save(ms, SaveFormat.Pdf);

// Here you should write contnet from memory stream into your response.

// ..........................................

}

Best regards,

Thank you very much, that is the solution! I still find it strange that it didn’t work the other way, but I’m glad it does now.


Greetings,

Ruben

Hi Ruben,

It is perfect that you managed to resolve the problem. Please let us know if you need more assistance, we will be glad to help you.

Best regards,