Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 如何在IE11/Edge中成功嵌入blob PDF响应_Angularjs_Pdf_Internet Explorer 11_Microsoft Edge - Fatal编程技术网

Angularjs 如何在IE11/Edge中成功嵌入blob PDF响应

Angularjs 如何在IE11/Edge中成功嵌入blob PDF响应,angularjs,pdf,internet-explorer-11,microsoft-edge,Angularjs,Pdf,Internet Explorer 11,Microsoft Edge,我无法将blob url作为PDF嵌入IE 11/Edge中。存在CORS问题,IE发出“访问被拒绝”。从我对SO的研究中,我意识到这是由于IE固有的安全限制。我的问题是,是否有其他方法可以从REST服务获取blob URL数据响应并将其显示在浏览器中。我想避免使用任何第三方库。 服务返回如下所示: function getTest(id) { miEService.get(id) .then(function (response) {

我无法将blob url作为PDF嵌入IE 11/Edge中。存在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">


如果rest服务返回pdf的二进制数据,您可以将url作为Iframe而不是二进制内容本身嵌入页面中。它应该呈现pdf。如果没有,我在过去就成功地将pdf作为一个链接,当您单击链接时,它会在一个新选项卡中打开对rest服务的请求。如果问题是您不希望rest服务显示在页面的url中,那么您可能必须通过自己的服务器代理请求

谢谢!我已经用代码更新了我的问题。我试图使用URL.createObjectURL()从服务返回的响应中创建一个URL,然后显示它。但IE不允许这样。我正在试图找到另一种方法来获取并显示blob,而不是创建blob URL。@我不是说转换,而是说将框架URL设置为rest服务URL