【发布时间】:2018-12-19 03:01:49
【问题描述】:
我正在使用 Angular 作为前端,我正在从 REST 完整 Web 服务获取数据。 1) 我需要在 Web 浏览器的新窗口中显示 pdf 文件,我从 Web 服务获取数据为 base 64。
问题:我可以下载文件,但是当我尝试在新窗口中打开文件时,它会显示(错误:无法加载 pdf 内容)。这是我的代码:
服务:
this.http.get('https://localhost:44364/api/v1/source/GetImage/parameter1/animal.pdf', { responseType:'arraybuffer' })
.subscribe(response => {
var file = new Blob([response], {type: 'application/pdf'});
var fileURL = URL.createObjectURL(file);
this.content=this.sanitizer.bypassSecurityTrustResourceUrl(fileURL);
});
HTML:在 HTML 中我使用 IFRAME 来显示 pdf 数据
iframe class="e2e-iframe-trusted-src" width="640" height="390" [src]="content"
谁能帮帮我。谢谢
【问题讨论】: