需要在IE窗口中打开blob / PDF [英] Need to open blob/PDF in IE window

查看:1237
本文介绍了需要在IE窗口中打开blob / PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的打字稿中使用下面的代码来调用web api方法,并检索一个PDF的二进制字节数组(blob)。我的用户需求是在新窗口中打开PDF。

I have the code below in my typescript to call a web api method and retrieve a binary byte array (blob) that is a PDF. My user requirement is to open PDF in a new window.

$scope.selectRow = (itemImageNumber: string, printProcessId: string, printXmlId: string) => {
        itemService.GetOutgoingDocument($scope.item.ItemId, itemImageNumber, printProcessId, printXmlId).success((response) => {
            var file = new Blob([response], { type: 'application/pdf' });
            var fileUrl = URL.createObjectURL(file);
            //$scope.outDocContent = $sce.trustAsResourceUrl(fileUrl);
            var win = window.open($sce.trustAsResourceUrl(fileUrl));
            win.focus();
        }).error(() => {
            var message = 
                "The document you selected can’t be displayed at this time. Please call Customer Service at xxx-xxx-xxxx for assistance.";
            $rootScope.$broadcast("app-message", {
                type : "danger",
                message : message
            });
        });
    }

这段代码在Chrome中正常工作。文档按预期打开。然而,IE问道:你想让这个网站在你的电脑上打开一个应用程序吗?如果允许,告诉我没有安装应用程序来打开这种链接(blob)。

This code works fine in Chrome. The document opens as expected. IE however asks "Do you want to allow this website to open an app on your computer?" and when allowed, tell me "No apps are installed to open this kind of link (blob)".

关于如何在新标签页中打开或保存作为文件的blob作为最后的手段?

Any ideas on how to open this in a new tab or save the blob as a file as a last resort?

推荐答案

它在Chrome和其他普通浏览器中的工作原理是:预览器安装在它们内部。

The reason why it works in Chrome and other normal browsers: they have pdf previewer installed inside of them.

租约为什么在IE中不起作用:因为在IE中,应该在操作系统上安装一些PDF阅读程序;例如,如果您安装了Adobe Acrobat,您可以毫无问题地打开它。

The lease why it does not work in IE: since in architecture if IE there should be some PDF reading program installed on operating system; for instance, if you have Adobe Acrobat installed, you will open it without problems.

我可以推荐您使用: pdf.js /

这篇关于需要在IE窗口中打开blob / PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆