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

in firefox it does not trigger preview window #93

Closed
zoeyzou opened this issue Jan 30, 2019 · 17 comments
Closed

in firefox it does not trigger preview window #93

zoeyzou opened this issue Jan 30, 2019 · 17 comments

Comments

@zoeyzou
Copy link

zoeyzou commented Jan 30, 2019

I'm using firefox 65.0 64bit firefox with win10. When I try to print this https://codesandbox.io/s/vj843ljyk3 from chrome v71, a preview window will jump out. However on firefox, there's only a print window instead of preview window. If i try print the whole page from the settings, the preview window will be out but of course with all the unneccesary contents.

Is this a solved issue or to-solve issue? I cant find any reference.

@MatthewHerbst
Copy link
Owner

Please try using the newest version and let us know if it works or not: 2.0.0-alpha-6

@zoeyzou
Copy link
Author

zoeyzou commented Jan 30, 2019

Please try using the newest version and let us know if it works or not: 2.0.0-alpha-6

Hi The version i'm using is 2.0.0-alpha-6 and the issue exists on this version

@MatthewHerbst
Copy link
Owner

Interesting. When I test it, the print popup opens, but there is not image. Is that the same behavior you are seeing? I wonder if there's some flag we need to pass that's specific to Firefox, or something else.

@zoeyzou
Copy link
Author

zoeyzou commented Jan 30, 2019

Interesting. When I test it, the print popup opens, but there is not image. Is that the same behavior you are seeing? I wonder if there's some flag we need to pass that's specific to Firefox, or something else.

Yep, it only triggers the print window but not preview window. I didnt dig into it, but it might have something to do with tabs.printpreview(). Although this is for the whole tab preview, might have some workaround for iframe?

@MatthewHerbst
Copy link
Owner

tabs.printpreview() seems to be specifically for Firefox extensions, though it is interesting that they have two separate methods. It certainly might be related to iframes, potentially needing some sandbox features, though we don't print from inside an iframe, we simply print a page with an iframe. I'll try and dig into this this weekend

@akmur
Copy link

akmur commented Feb 12, 2020

I am getting this or a similar issue on Firefox mobile, reported by Sentry:

e.contentWindow.print is not a function

I tried myself and indeed the pdf is not shown

@Andersclark
Copy link

Did you find a solution? I'm having this issue right now.

@akmur
Copy link

akmur commented Mar 16, 2020 via email

@Andersclark
Copy link

Andersclark commented Mar 29, 2020 via email

@MatthewHerbst
Copy link
Owner

MatthewHerbst commented Apr 12, 2020

I am adding in a check for this, as well as an error message specifying that printing cannot happen because the browser does not support .print on iframes. I would love to find an actual fix for this since it seems strange to me that Mobile Firefox wouldn't support printing. I should note that the way we print is exactly the way MDN suggests printing a hidden iframe:

contentWindow.focus(); // Required for IE
contentWindow.print();

@Andersclark
Copy link

Andersclark commented Apr 18, 2020

**@MatthewHerbst -Thanks for getting back to me!

I suppose we are talking about two issues:**

  1. Firefox Android not supporting window.print()
  2. Firefox desktop not showing preview when calling window.print() (though it has printpreview as a menu option).

I'm mostly concerned with the second one, since I bothered writing a component for printing, which is now not displayed in FF. As far as I can tell, FF simply does not have an interface for previewing prints. The window.print()-method does not do this on FF and since preview is a browser feature, not a W3C-standard it cannot be force, only the menu option triggers preview. But maybe you could try
tabs.printPreview() ? Documented here: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/printPreview

About the FF for Android-issue: It seems like they simply do not support the API at all:
bild

@MatthewHerbst
Copy link
Owner

I'll take a look at printPreview tonight, thanks!

@MatthewHerbst
Copy link
Owner

MatthewHerbst commented Apr 19, 2020

@Andersclark there is some really good (and really long) discussion about all of this in this bug report/feature request/pr, which is where the FireFox only browser.tabs.printPreview came into being.

It seems that Firefox opening the print dialog on window.print instead of the print preview dialog is intentional (why I couldn't tell you). This is also the behavior when using Ctrl+P/CMD+P to print the page, though, strangely enough, if you use the (hidden by default) print toolbar button it does open the print preview dialog. They recognize that it's not what other browsers (Chrome for example) do, and instead of fixing it, they introduce the browser.tabs.printPreview method to solve the problem.

However, browser.tabs.printPreview open a print preview dialog for the current active tab. react-to-print prints the contents of a hidden iframe. I haven't been able to find a way to use tabs.printPreview to print the contents of a hidden iframe. Do you have any thoughts on that?

@sunilb0575
Copy link

I am using the latest version of firefox and still don't get the print preview and also not able to print.
I see this error in the console: SecurityError: CSSStyleSheet.cssRules getter: Not allowed to access cross-origin stylesheet

Is this issue fixed?
@MatthewHerbst

@MatthewHerbst
Copy link
Owner

Hi @sunilb0575 If you read above, you will see that, AFAIK, there is no ability to programmatically show the print preview window in Firefox for an arbitrary iframe. If you know of a way to do so, or know someone who might, please direct them here or to the linked SO question.

As for the error you are getting, can you please create a codesandbox or similar that I can use to replicate that? I just checked the demo example on the latest Firefox and it works without issue. I would also suggest you create a new issue for the error.

@sunilb0575
Copy link

Thanks, @MatthewHerbst the not-printing issue was happening because of a plugin on my local. So I am good now.

@lrkwz
Copy link

lrkwz commented Mar 1, 2022

Ubuntu 20.04 focal fossa
firefox 97.0

I had the same problem with the "Autofill" extension enabled. Disabling it fixes the problem. As a diagnose technique I suggest to use the "Private mode".

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

No branches or pull requests

6 participants