From 9106c505a5bd6d8e3f02729428a563751a0c5505 Mon Sep 17 00:00:00 2001 From: Paul Lambert Date: Sat, 27 Jun 2015 09:07:11 +1200 Subject: [PATCH] Fix(exporter): fix #3642 export pdf in IE 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). --- src/features/exporter/js/exporter.js | 37 ++++++++++++++-------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/features/exporter/js/exporter.js b/src/features/exporter/js/exporter.js index a9fe0892c3..1d9f2faf6b 100644 --- a/src/features/exporter/js/exporter.js +++ b/src/features/exporter/js/exporter.js @@ -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 + ); + } + }); },