I’m trying to take a doc file and convert to pdf and send to browser. I can get it to save to a file, but I don’t want to do it this way.
Can you show me the right way of taking a document and doing this?
This is my sample code. I am getting a Specified method is not supported error on the .Save line. I am using the latest dlls and running this in Chrome.
Thanks for your inquiry. Most likely you are using Aspose.Words .NET 3.5 Client Profile; .NET 3.5 Client Profile excludes System.Web and therefore HttpResponse is not available. This is entirely by design. If you need to use Aspose.Words in ASP.NET application, I would recommend you use .NET 2.0 Client Profile assembly and the following overload of Save method:
Thanks for your inquiry. Most likely you are using Aspose.Words .NET 3.5 Client Profile; .NET 3.5 Client Profile excludes System.Web and therefore HttpResponse is not available. This is entirely by design. If you need to use Aspose.Words in ASP.NET application, I would recommend you use .NET 2.0 Client Profile assembly and the following overload of Save method:
Thank you for inquiry. You can also use this code snippet with .NET 3.5
Document doc = new Document(fileName);
MemoryStream stream = new MemoryStream();
doc.Save(stream, SaveFormat.Doc);
Response.Clear();
//Specify the document type.
Response.ContentType = “application/doc”;
//Other options:
[//Response.ContentType](https://response.contenttype/) = “text/plain”
[//Response.ContentType](https://response.contenttype/) = “text/html”
//Specify how the document is sent to the browser.
Response.AddHeader(“content-disposition”, “attachment; filename=MyDocument.doc”);
//Another option could be:
[//Response.AddHeader](https://response.addheader/)(“content-disposition”, “inline; filename=out.doc”);
//Get data bytes from the stream and send it to the response.
byte[] bytes = stream.GetBuffer();
Response.BinaryWrite(bytes);
Response.End();