I need to print a PDF file which I obtain through a GET request in JavaScript. In order to do the actual printing I use PrintJS, which can be used to print from a specific PDF URL.
My code looks something like this:
printChart() {
var req = new XMLHttpRequest();
req.open('GET', 'http://localhost:8080/test.pdf', true);
req.responseType = 'blob';
req.onload = function (event) {
var blob = req.response;
var blobURL = window.URL.createObjectURL(blob);
printJS(blobURL);
};
req.send();
}
This works fine in Chrome, but the problem is it does not print anything in Internet Explorer (tested in IE 11). Apparently, window.URL.createObjectURL does not work properly in IE.
Although there is a msSaveOrOpenBlob method in IE but this doesn't help me very much, since I need to print the PDF, not to save it.