首页 > 解决方案 > 使用角度在IE中打开流pdf

问题描述

我会在导航器中打开一个 pdf 文件

实际上 Chrome 正在工作。当单击文件 pdf 在新窗口中打开时

public openFile(path) {
  let url='/download/';
  let headers = new HttpHeaders();
  let pathFile= new HttpParams().set('pathFile', path);
  return this.httpClient.get(url,{params:pathFile, responseType: 'blob'})
}

然后在我的组件中

openFile(path){
  this.creditPoliciesService.openFile(path).toPromise().then (data => {
    var blob = new Blob([data], {type: 'application/pdf'}); 
    var fileURL = URL.createObjectURL(blob); 
    window.open(fileURL);
});

在 Internet Explorer 和 Firefox 中,当我单击链接时,会打开一个新选项卡,然后在 url 栏中我得到这个地址blob:http://......code....

如何在 IE 中读取 blob?

标签: angularinternet-explorerblob

解决方案


推荐阅读