正如磁贴所暗示的,我正在尝试打印一个专门针对IE11的PDF报告。下面的代码片段可以在chrome中运行,但是当它涉及到IE11时,所有的地狱都会松动;没有什么可以运行。为了给你一个背景,我正在开发Angular 5报表应用程序。在这里,用户可以查看、下载和打印报告。除了在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();任何意见都是值得感谢的。
发布于 2020-06-19 20:16:28
我能够在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上工作
https://stackoverflow.com/questions/50685552
复制相似问题