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

Free Support Forum - aspose.com

How to save a PDF to user's local drive

Hello all,


I have a small component that uses Aspose.Words for .NET API to convert a Word to PDF document.

As explained in this example, I tried sending the converted document to the client browser. And I expected to see a little pop-up on the bottom of the screen that indicates the document is being downloaded to the client’s local disk. But instead, the document automatically opens itself up in the current browser, which is not a desirable outcome.

I looked at all other examples listed under the “Save a Document” section, but none of them seems to yield the required result. Is there a way I can just force a PDF document to be downloaded to the client browser when the ‘Save’ method is invoked?

Okay, I think I solved my problem.


The Aspose example for sending the document to the client browser is as follows:

doc.Save(Response, “Converted_Document.pdf”, ContentDisposition.Inline, null);

All I had to do to force a “Save to local” option is simply use the ‘Attachment’ option, so the code should be modified as:

doc.Save(Response, “Converted_Document.pdf”, ContentDisposition.Attachment, null);

Oddly enough, I didn’t find out about this in Aspose support site, but I had to search for it online. Unless, of course, I missed it in the Aspose site.

Hi Kyung,

Thanks for your inquiry. It is nice to hear from you that you have found the solution of your query. Please read about ContentDisposition enumeration from here:
http://www.aspose.com/docs/display/wordsnet/Aspose.Words.ContentDisposition+Enumeration