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

Free Support Forum - aspose.com

Doc -> PDF -> Save in Browser

Hi i am manipulating a word document in my code.


I then want to convert this word document into a pdf document and then create a file download in the browser of my web application.

I am utilizing the following code:

MemoryStream stream = new MemoryStream();
doc.Save(stream, SaveFormat.Pdf);
byte[] bytes = stream.GetBuffer();

Response.Clear();
//Specify the document type.
Response.ContentType = “application/pdf”;
//Other options:
// Response.ContentType = “application/msword”
//Response.ContentType = “text/plain”
//Response.ContentType = “text/html”
//Specify how the document is sent to the browser.
Response.AddHeader(“content-disposition”, “attachment; filename=”+fileName);
//Another option could be:
//Response.AddHeader “content-disposition”,“inline; filename=MyDocument.doc”;
//Get data bytes from the stream and send it to the response.
Response.BinaryWrite(bytes);
Response.End();

which i found in one of the topics here.

When i do so, i dont get any file download or anything nothing really happens. When i check the response message the pdf is in the response everything is okay i just dont get any save file.

Also in addition to that:

i have the Aspose.Words assembly 2.0 dll included in my project ( which is mvc 4.0 ) but the doc.Save overload method still does not work, why is that?

Hi Robert,


Thanks for your inquiry. I would suggest you please read the following article that outlines ‘how to send a document to client’s browser’:
http://www.aspose.com/docs/display/wordsnet/Sending+to+a+Client+Browser

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