0

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
  • Are you trying to do this using AJAX?
    – SLaks
    Oct 19, 2010 at 0:34
  • i'm using jQuery and $.ajax (sending a 'post')
    – Fuxi
    Oct 19, 2010 at 0:45

1 Answer 1

2

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>)

3
  • 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
    Oct 19, 2010 at 0:30
  • Try setting Content-Type to application/octet-stream.
    – SLaks
    Oct 19, 2010 at 0:34
  • already did - nothing happens still .. my code: m_file = "mypdf.pdf" Response.ContentType = "pdf" Response.AddHeader "content-disposition", "attachment; filename=""" & m_file & """" Response.ContentType = "application/octet-stream"
    – Fuxi
    Oct 19, 2010 at 0:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.