i am using blob url and iFrame to print document. It's work fine in Chrome but not working in IE.
can anyone tell me how to print blob url set in iframe src?
let file = new Blob([res.blob()], { type: 'application/pdf' });
let blobURL = URL.createObjectURL(file);// here file is blob object
let iframe = document.createElement('iframe');
document.getElementById('viewerContainer').appendChild(iframe);
iframe.onload = function () {
iframe.contentWindow.print();
};
iframe.src = blobURL;
I don't know the specific case of IE7 but I had a similar error with Firefox. This one triggers the onload event before the content is fully loaded. Unfortunately, I couldn't find a solution. So I cunningly used a setTimeout().
This solution is weak but you can use setTimeout(time) with a time that will allow you to load the full content of the document. Warning this time depends on the network connection
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.