私のtypecriptに以下のコードがあり、Web APIメソッドを呼び出し、PDFであるバイナリバイト配列(BLOB)を取得します。私のユーザーの要件は、新しいウィンドウでPDFを開くことです。IEウィンドウでBLOB/PDFを開く必要があります
$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)を開くためのアプリはインストールされていません」と教えてください。
これを新しいタブで開く方法や、最後の手段としてファイルとして保存する方法に関するアイデアはありますか?
野生の推測:いくつかのヘルプの可能性があります同様に探している質問があります:http://stackoverflow.com/questions/28196065/downloading-pdf-as-blob-with-js-in-ie9、http: /stackoverflow.com/questions/24007073/open-links-made-by-createobjecturl-in-ie11具体的には、このIE固有の行は興味深いかもしれません: 'window.navigator.msSaveOrOpenBlob(blobObject、fileName);' –