AngularJS: download pdf file from the server

前端 未结 2 1422
慢半拍i
慢半拍i 2020-12-06 07:41

I want to download a pdf file from the web server using $http. I use this code which works great, my file only is save as a html file, but when I open it it is

相关标签:
2条回答
  • 2020-12-06 08:14

    To instruct the browser to download the file instead of showing it in the browser, try the add following headers to the server response:

    Content-Disposition:attachment; filename="filename.xxx"
    Content-Type:application/octet-stream
    
    0 讨论(0)
  • 2020-12-06 08:22

    Default Open-In Application:

    Based on the screenshot, it looks like you have set Firefox as the default application to open your PDF documents on that computer. Which it does, using it's embedded viewer.

    So it is saving as a PDF, but your open-in application preferences make it appear as Firefox Html Document.

    If you change the open-in preference back to Adobe Reader then the Save-As type should display correctly in the browser.

    I hope that helps.

    0 讨论(0)
提交回复
热议问题