As the tile suggest, I am trying to print a PDF report specifically on IE 11. The following snippet of code works will in chrome, but when it come to IE11, all hell breaks loose; nothing works. To give you a background, I am developing Angular 5 reporting application. Here the user can view, download and print the report. I was able to achieve all the above functionalities except for printing on IE 11!
const iframe = document.createElement('iframe');
iframe.style.display = 'none';
iframe.src = window.URL.createObjectURL(new Blob([result], { type: 'application/pdf' }));
document.body.appendChild(iframe);
iframe.contentWindow.print();
Any input is appreciated.
答案 0 :(得分:0)
我能够在IE上打印,这是我学到的一个小技巧,它可以正常工作。
const iframe = document.createElement('iframe');
iframe.style.display = 'none';
iframe.src = window.URL.createObjectURL(new Blob([result], { type: 'application/pdf' }));
document.body.appendChild(iframe);
iframe.load = () => {
setTimeout(() => {
iframe.focus();
iframe.contentWindow.print();
});
};
通过此黑客,它可以在最新的IE上运行