【发布时间】:2017-03-14 23:22:09
【问题描述】:
我无法在 IE 11/Edge 中将 blob url 作为 PDF 嵌入。存在 CORS 问题,IE 给出“拒绝访问”。从我对 SO 的研究中,我意识到这是由于 IE 固有的安全限制。我的问题是有没有其他方法可以从 REST 服务获取 blob URL 数据响应并将其显示在浏览器中。我想避免使用任何第三方库。 服务返回如下:
function getTest(id) {
miEService.get(id)
.then(function (response) {
var fileUrl = URL.createObjectURL(response.data);
$scope.pdfData = $sce.trustAsResourceUrl(fileUrl);
});
get: function (id) {
var config = {
headers: {
accept: 'application/pdf'
}
, responseType: 'blob'
}
return $http.get(miEnv.services.eApi + '?$filter=id eq' +
' ' + id, config);
最后在html里面显示如下-
<object id="pdf" data={{$ctrl.pdfData}} type="application/pdf" width="100%" height="100%" alt="pdf" class="view-pdf_document">
【问题讨论】:
标签: angularjs pdf internet-explorer-11 microsoft-edge