Skip to content

Commit

Permalink
Fix(exporter): fix #3642 export pdf in IE
Browse files Browse the repository at this point in the history
Should download pdf similar to downloading a csv when in IE, whereas
all other browsers should open the pdf in place in a new tab (something
that pdfMake cannot do in IE).
  • Loading branch information
PaulL1 committed Jun 26, 2015
1 parent 3253caf commit 9106c50
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions src/features/exporter/js/exporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -991,30 +991,31 @@
ieVersion = this.isIE();
var doc = pdfMake.createPdf(docDefinition);
var blob;

doc.getBuffer( function (buffer) {
blob = new Blob([buffer]);
});

if (ieVersion && ieVersion < 10) {
var frame = D.createElement('iframe');
document.body.appendChild(frame);
if (ieVersion && ieVersion < 10) {
var frame = D.createElement('iframe');
document.body.appendChild(frame);

frame.contentWindow.document.open("text/html", "replace");
frame.contentWindow.document.write(blob);
frame.contentWindow.document.close();
frame.contentWindow.focus();
frame.contentWindow.document.execCommand('SaveAs', true, fileName);
frame.contentWindow.document.open("text/html", "replace");
frame.contentWindow.document.write(blob);
frame.contentWindow.document.close();
frame.contentWindow.focus();
frame.contentWindow.document.execCommand('SaveAs', true, fileName);

document.body.removeChild(frame);
return true;
}
document.body.removeChild(frame);
return true;
}

// IE10+
if (navigator.msSaveBlob) {
return navigator.msSaveBlob(
blob, fileName
);
}
// IE10+
if (navigator.msSaveBlob) {
return navigator.msSaveBlob(
blob, fileName
);
}
});
},


Expand Down

0 comments on commit 9106c50

Please sign in to comment.