-3
var newPDF = window.open(this.generatedPDF.output('bloburl'), '_blank');
newPDF.print();

This code is working perfect in Chrome but in IE while using this code I am getting a warning

DO YOU WANT TO ALLOW THIS WEBSITE TO OPEN AN APP ON YOUR COMPUTER ?

On click of YES , I am getting this

YOU WILL NEED A NEW APP TO OPEN BLOB

What is the possible solution for IE ?

mplungjan
  • 169,008
  • 28
  • 173
  • 236
  • A question that has been asked like a million times... https://stackoverflow.com/questions/24007073/open-links-made-by-createobjecturl-in-ie11 – Lumpenstein Oct 09 '19 at 12:16

1 Answers1

0

From your description, I suppose you want to display the PDF file in the browser, then print it.

As far as I know, IE 11 blocks display of blob, if you want to display them, first we need to download it, then view it from locally.

So, I suggest you could try to refer to the following code, when using IE browser download the file first, then print them, when using another browser you could use your code to print them:

            // if Internet Explorer or Edge is used, download it.
            if (window.navigator && window.navigator.msSaveOrOpenBlob) {
                var byteCharacters = atob(result.document);
                var byteNumbers = new Array(byteCharacters.length);
                for (var i = 0; i < byteCharacters.length; i++) {
                    byteNumbers[i] = byteCharacters.charCodeAt(i);
                }
                var byteArray = new Uint8Array(byteNumbers);
                var blob = new Blob([byteArray], {
                    type: 'application/pdf'
                });
                window.navigator.msSaveOrOpenBlob(blob, "output.pdf");
            // for all other web browsers
            } else { 
                //your code to print them
            }    

Reference:

Displaying binary file (pdf) in IE 11

How to print Pdf file through window.Print() ?

How to open a pdf downloaded from an API with JavaScript

Zhi Lv
  • 18,845
  • 1
  • 19
  • 30