tags:

views:

20

answers:

1

hi,

i'm using asp + asppdf (a component for creating pdf files). asppdf has a method called SaveHTTP which causes the browser to open the "save-as" dialog for saving the pdf. so the component is sending the pdf as binary data to the browser.

my question: i'd like to load the pdf via xmlhttp + then open that dialog. loading works (i'm getting the data) - but i'm not sure how to call the save-as dialog.

any ideas if it's possible?

thanks

+2  A: 

You need to add a Content-Disposition: attachment header to the HTTP response.

EDIT: It is not possible to show a save dialog using AJAX.
Instead, you can set location.href to the PDF URL (with Content-Disposition: attachment), which will do what you're trying to accomplish. (You could also POST a <form> in a hidden <iframe>)

SLaks
thanks for your answer. in my serverscript i added the header like this: Response.AddHeader "content-disposition", "attachment; filename=""myfile.pdf"""should be right - i can see the header in firebug but - no save-as-dialog :(
Fuxi
Try setting `Content-Type` to `application/octet-stream`.
SLaks
Fuxi