Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Printing from iframe in IE11 prints surrounding page instead of document #10847

Closed
kleins05 opened this issue May 22, 2019 · 3 comments
Closed

Comments

@kleins05
Copy link
Contributor

kleins05 commented May 22, 2019

Note:
This was reported before in #7711 and probably in #6152, but incorrectly closed as fixed or not relevant

Configuration:

  • Web browser and its version: IE 11.0.9600.19356, Update Version 11.0.125
  • Operating system and its version: Windows 7
  • PDF.js version: 2.0.943
  • Is a browser extension: no

Steps to reproduce the problem:

  1. Load viewer into iframe
  2. Trigger a print using javascript from the main page (iframe.contentWindow.print())

Testcase
https://kleins05.github.io/pdf.js/test-ieiframe/
(load in IE11, click print button, check print output)

What is the expected behavior?
The PDF in the iframe should be printed.

What went wrong?
The surrounding page is printed.
Screen Shot 2019-05-22 at 13 21 01

@Snuffleupagus
Copy link
Collaborator

Printing support in IE11 is limited in general, furthermore please refer to the relevant section of the FAQ:

While the library and the default viewer should still work in IE 11/Edge (non-Chromium-based) for the time being, some functionality/features may not be available and the performance will be worse compared to modern browsers. Going forward, only bugs which completely prevent the library and/or the default viewer from running will be accepted.

@kleins05
Copy link
Contributor Author

I found the reason. Unlike other browsers window.print in IE causes the currently focused frame/window to print, not necessarily the one that window refers to. Using document.execCommand avoids this.

In web/pdf_print_service.js:187 instead of print.call(window); use:

var result = window.document.execCommand('print', false, null);
if (!result) {
   print.call(window);
}

If you are happy to accept a pull request in spite of your limited support of IE11, I am willing to create one. Let me know.

@Snuffleupagus
Copy link
Collaborator

Snuffleupagus commented May 22, 2019

If you are happy to accept a pull request in spite of your limited support of IE11,

Unfortunately we've never accepted compatibility "hacks" placed in the main code-base, for various reasons such as e.g. readability/maintainability/performance, and those were always restricted to polyfills placed in https://github.com/mozilla/pdf.js/blob/master/src/shared/compatibility.js

Furthermore, at this point in time a bug needs to prevent using the library at all in IE11 to be considered valid. (Expect a future PDF.js release, which one still to be decided as far as I know, to mark IE11 as explicitly unsupported and remove what little compatibility code that remains. Historically trying to support IE11 has restricted the ability to use modern JavaScript features, and has forced contributors to spend a lot of time supporting an essentially dead browser.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants