小编Rit*_*rma的帖子

如何在 Angular 2 中下载 pdf 文件

这是在 Angular 2 中下载 pdf 文件的功能,当我下载 Pdf 文件时,它是损坏的文件。那么我该如何解决这个问题。\n它显示的是这样的损坏数据。\n%PDF-1.5\n%\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd \n\xe2\x86\xb566 0 对象\n<>\nendobj

\n\n
downloadFile() {\n    //this.http.get('https://contactsapi.apispark.net/v1/companies/').subscribe(\n    this.http.get('assets/Files/booking.pdf').subscribe(\n      (response: any) => {\n        console.log(response);\n        let parsedResponse =(response)\n        var blob = new Blob([response], {type: 'application/pdf'});\n        var filename = 'booking.pdf';\n        saveAs(blob, filename);\n      });\n  }\n
Run Code Online (Sandbox Code Playgroud)\n

angular2-services

5
推荐指数
2
解决办法
3万
查看次数

标签 统计

angular2-services ×1