Skip to content

Commit e0cf819

Browse files
committed
Merge pull request #4640 from imbalind/issue4557
Fix For Windows 10 Exporter
2 parents 4189272 + 49b6e47 commit e0cf819

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

src/features/exporter/js/exporter.js

100644100755
Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -884,8 +884,14 @@
884884
* @description Checks whether current browser is IE and returns it's version if it is
885885
*/
886886
isIE: function () {
887-
var match = navigator.userAgent.match(/(?:MSIE |Trident\/.*; rv:)(\d+)/);
888-
return match ? parseInt(match[1]) : false;
887+
var match = navigator.userAgent.search(/(?:Edge|MSIE|Trident\/.*; rv:)/);
888+
var isIE = false;
889+
890+
if (match !== -1) {
891+
isIE = true;
892+
}
893+
894+
return isIE;
889895
},
890896

891897

@@ -1015,14 +1021,24 @@
10151021
var rawFile;
10161022
var ieVersion;
10171023

1018-
ieVersion = this.isIE();
1024+
ieVersion = this.isIE(); // This is now a boolean value
10191025
var doc = pdfMake.createPdf(docDefinition);
10201026
var blob;
10211027

10221028
doc.getBuffer( function (buffer) {
10231029
blob = new Blob([buffer]);
10241030

1025-
if (ieVersion && ieVersion < 10) {
1031+
// IE10+
1032+
if (navigator.msSaveBlob) {
1033+
return navigator.msSaveBlob(
1034+
blob, fileName
1035+
);
1036+
}
1037+
1038+
// Previously: && ieVersion < 10
1039+
// ieVersion now returns a boolean for the
1040+
// sake of sanity. We just check `msSaveBlob` first.
1041+
if (ieVersion) {
10261042
var frame = D.createElement('iframe');
10271043
document.body.appendChild(frame);
10281044

@@ -1035,13 +1051,6 @@
10351051
document.body.removeChild(frame);
10361052
return true;
10371053
}
1038-
1039-
// IE10+
1040-
if (navigator.msSaveBlob) {
1041-
return navigator.msSaveBlob(
1042-
blob, fileName
1043-
);
1044-
}
10451054
});
10461055
},
10471056

0 commit comments

Comments
 (0)