React-to-print: in firefox it does not trigger preview window

Created on 30 Jan 2019  Â·  16Comments  Â·  Source: gregnb/react-to-print

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.

Firefox Upstream bug

All 16 comments

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

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

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.

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?

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

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

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

Hi, no, I just disabled it on firefox mobile, while on normal firefox it
seems to work fine

On Fri, 13 Mar 2020 at 13:56, Andersclark notifications@github.com wrote:

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

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/gregnb/react-to-print/issues/93#issuecomment-598706259,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAHJ3EID3N7AB4RUUEIZMZ3RHIUPVANCNFSM4GTGN62A
.

--
Alessandro Muraro

LinkedIn https://www.linkedin.com/in/alessandromuraro/ - alexmuraro.me

Yeah. I seemed to have plugins interfering...

On Mon, Mar 16, 2020, 08:39 Alex Muraro notifications@github.com wrote:

Hi, no, I just disabled it on firefox mobile, while on normal firefox it
seems to work fine

On Fri, 13 Mar 2020 at 13:56, Andersclark notifications@github.com
wrote:

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

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<
https://github.com/gregnb/react-to-print/issues/93#issuecomment-598706259
,
or unsubscribe
<
https://github.com/notifications/unsubscribe-auth/AAHJ3EID3N7AB4RUUEIZMZ3RHIUPVANCNFSM4GTGN62A

.

--
Alessandro Muraro

LinkedIn https://www.linkedin.com/in/alessandromuraro/ - alexmuraro.me

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/gregnb/react-to-print/issues/93#issuecomment-599387774,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ABLR3YZXYAZL377DV4LRXJ3RHXJSLANCNFSM4GTGN62A
.

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();

**@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

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

@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?

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

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.

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JoshuaKGoldberg picture JoshuaKGoldberg  Â·  3Comments

sprietNathanael picture sprietNathanael  Â·  4Comments

erangia picture erangia  Â·  7Comments

k-jiang picture k-jiang  Â·  5Comments

icebravo picture icebravo  Â·  5Comments