Outside to iFrame, and with outher browsers it's all ok!
Into IE11 iframe not.
<iframe src="http://mozilla.github.io/pdf.js/web/viewer.html"></iframe>
Configuration:
Steps to reproduce the problem:
Print outside iframe:
Print into iframe:
Wrong:
Could you help me? thanks!
While I'm not entirely sure why, IE11 (and older version of IE) has issues with using window.print
in an iframe. Using window.document.execCommand('print', false, null);
seems to get the desired results, but is not supported in Firefox.
If you are building pdf.js from source, you can change print.call(window)
in pdf_print_service.js
to this:
if (document.queryCommandSupported('print')) {
window.document.execCommand('print', false, null);
} else {
print.call(window);
}
For a more complete solution, you might also want to check if you are in an iframe.
Great! Print space is ok now, but I have one more issue ... Print doesn't take the correct page orientation. Below an example of landscape page, but printed with portrait orientation ... (always with IE11 and iFrame) ...
Thanks!!
solution by kimgronqvist worked for margin issue. But it created a new issue for me.
I had a custom event listener for "afterprint" event like below.
someiframe.contentWindow.addEventListener("afterprint", function() {
window.close();
});
This event doesn't trigger in IE after the margin fix. Fine in chrome.... Any ideas?
Same issue here, can this be fixed inside the package?
Try setTimeout like:
someiframe.contentWindow.addEventListener("afterprint", function() {
setTimeout(function(){
window.close();
}, 1000)
});
In Internet Explorer锛宼he JavaScript thread will be blocked when the print dialog appears. So try to use setTimeout to make it execute when the thread resumes (close the print dialog)
I am also experiencing this in IE, but @kimgronqvist's solution did not fix it. Is there an official solution to this issue?
I face with same problem. @kimgronqvist's solutions work from time to time.
Will this issue be fixed in official package?
Closing IE11/Edge (non-Chromium-based) issues in response to #11211. Please note that, as outlined in https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions#faq-support, only bugs which completely prevent the library and/or the default viewer from running will be accepted.
Most helpful comment
While I'm not entirely sure why, IE11 (and older version of IE) has issues with using
window.print
in an iframe. Usingwindow.document.execCommand('print', false, null);
seems to get the desired results, but is not supported in Firefox.If you are building pdf.js from source, you can change
print.call(window)
inpdf_print_service.js
to this:For a more complete solution, you might also want to check if you are in an iframe.