Print.js icon indicating copy to clipboard operation
Print.js copied to clipboard

Browser support

Open clluiz opened this issue 7 years ago • 38 comments

What browsers and version are supported?

clluiz avatar Mar 17 '17 18:03 clluiz

@clluiz I need to run more tests and create a list for this. Everything works in Google Chrome. Firefox won't print PDF, but the library identifies and open the pdf file in a separate tab. Safari won't print images properly, as well Edge. Last time I tested in IE everything worked, version 11. However, some people reported issues IE, don't remember what version. I may keep this issue open so people can start reporting browser compatibility here. I would appreciate any help with this. Tests can be easily done using the documentation page: http://printjs.crabbly.com

crabbly avatar Mar 17 '17 18:03 crabbly

Can we, by any chance write automated tests to test browser support?

baransu avatar Mar 20 '17 16:03 baransu

Great idea. A quick search brought me to this: https://www.browserstack.com/javascript-testing-api

crabbly avatar Mar 20 '17 16:03 crabbly

I added a browser compatibility table to the documentation. Based on my tests using the browsers latest versions. http://printjs.crabbly.com/#browsers Thinking about adding a compatibility check to the library, to alert the user if a requested feature isn't working on the browser being used. At least untill all features are consistently working between browsers.

crabbly avatar Apr 03 '17 21:04 crabbly

It prints PDF in IE 11 when using Windows 7 SP1

coolbbeans avatar Apr 11 '17 20:04 coolbbeans

Hi, I'm a total newbie when it comes to contributing but I'd like to try to help out and maybe improve my skills in the process. I'm using your library for one of my projects so I thought this might be a good place to start.

One of the issues I've encountered is the lack of browser support for pdf printing in Firefox which actually led me here. I'm completely clueless as to how to fix that, but hopefully I can try to contribute in other ways and work my way up slowly until I have a solid foundation about the library.

Is there anything I need to know like proper etiquette, etc. before contributing to the project?

dacster13 avatar Nov 25 '17 08:11 dacster13

@dacster13 Hey Dexter, any contributions are welcome. The library code follows the style defined here: https://standardjs.com/ Run npm test after you are done making changes, it will show you of any style changes that may need be made before you commit.

About Firefox, the issue is because of their pdf.js implementation. There is a reported bug with mozilla: https://bugzilla.mozilla.org/show_bug.cgi?id=911444

crabbly avatar Nov 25 '17 15:11 crabbly

I think Print.js does not work for printing PDFs in Opera (Ubuntu). I tested Opera with a PDF and it tried to print the PDF from an iframe, which did not work.

gabrieldeal avatar Dec 18 '17 22:12 gabrieldeal

@gabrielmdeal Hey Gabriel, do you get any console error messages? I tested it with Opera in MacOS and it works fine. Any help is appreciated. Thx.

crabbly avatar Dec 18 '17 22:12 crabbly

I dug a bit more and found that this was a problem in Opera 43.0.2442.806, but it is no longer a problem after I upgraded to Opera 49.0.2725.64. So probably not worth pursuing.

FWIW, in Opera 43.0.2442.806's there was no error, but there was this warning:

Resource interpreted as Document but transferred with MIME type application/pdf

Opera 49.0.2725.64 also gives the warning, but the print dialog still opens.

gabrieldeal avatar Dec 19 '17 17:12 gabrieldeal

The warning is issued because of how we use the iframe to load the pdf file. Chrome does the same. It won't affect the print job. Thank you, Gabriel.

crabbly avatar Dec 19 '17 17:12 crabbly

Am using chrome 62. Any idea why why its opening pdf instead of silent printing?

darlie2014 avatar Feb 02 '18 15:02 darlie2014

@darlie2014 , According to the screen shot you posted in #122 , chrome is not opening the pdf, but instead, displaying the print preview, as expected. Other browsers may not show a preview, but they should still show a print options screen before sending the job to the printer. We can't bypass that with javascript, for security reasons. Reference #79

crabbly avatar Feb 02 '18 20:02 crabbly

print with json data doesn't work in chrome Version 65, just open a bland print preview

felixmayeya avatar Mar 07 '18 07:03 felixmayeya

Hey @felixmayeya , Which OS and version?

crabbly avatar Mar 07 '18 20:03 crabbly

macOS High Sierra, version 10.13.3 @crabbly

felixmayeya avatar Mar 08 '18 09:03 felixmayeya

Yeah, prinjs don’t work on las version of chrome (leased yersteday). On both OS (windows and OS X)

igormages avatar Mar 08 '18 10:03 igormages

I have confirmed this. The latest version of Chrome, v65, is not printing any iframe data, therefore a blank page. I'm not sure what to do about this yet. Printing PDF's still works though.

crabbly avatar Mar 08 '18 15:03 crabbly

I tried printing on iPad - iOS Safari and when trying to print PDF, additional margins are added making it unusable (iOS Chrome does not work at all).

robertsolarik avatar Mar 19 '18 16:03 robertsolarik

Any news on this? Libraries like PDFjs manage to print in Edge or IE so it should be possible.

AlexandrosG avatar Nov 20 '18 12:11 AlexandrosG

Hi @AlexandrosG, what other libraries do the same job as pdf.js?

PDF.js process the PDF document and create a HTML structure with the page images, and then print the document using that. If you go to their demo page, and care to look at the DOM tree, you will see a div element with id printContainer being setup when printing the document. I'm attaching a screenshot for reference.

pdfjs

Print.js tries to print the PDF directly using an iframe. Processing the PDF document, like pdf.js, would require a lot more code which is beyond the library scope. It would be nice to integrate with pdf.js and just use it to print (I didn't check, but I would guess it does have an API that would allow that). We could have this feature as an optional dependency to add better browser support. The reason I say it would need to be optional, is because this could not be of interest to many environments (conflicts, bundle size, etc). Either way, that's an option I think we could explore.

crabbly avatar Nov 24 '18 06:11 crabbly

Hello @crabbly,

In Firefox and Safari the URL is not shown correctly. It just says about:srcdoc. I've seen this even on the official page https://printjs.crabbly.com/. Is there some way to fix this or are there plans for a fix in the future?

Thank you, Dan

Dan-Chiriac avatar Jun 28 '19 13:06 Dan-Chiriac

Hi @Dan-Chiriac, this is the default behavior from those browsers. I'm not sure we can control that. For supported browsers, like Safari, you can try to use the documentTitle parameter. https://printjs.crabbly.com/#configuration

crabbly avatar Jun 29 '19 23:06 crabbly

It is really sad that this does not work for Mozilla Firefox. I don't understand why Firefox is always trying not to be a good browser such Chrome etc.

didagu avatar Sep 11 '19 06:09 didagu

@crabbly I don't really have time to make a proper PR for you, but I just want to throw this code your way. I finally got Edge printing properly with PDF's using this:

                var printframeid = "iframe-report-print";
                var $iframe = $("#" + printframeid);
                0 === $iframe.length && ($iframe = $("<iframe/>"), $iframe.attr("id", printframeid),
                    $iframe.css({
                        width: "1px",
                        height: "1px",
                        display: "none",
                        position: "fixed",
                        left: "0",
                        right: "0"
                    }), $("body").append($iframe)), $iframe.attr("src", uri);
                $iframe.on("load", function () { $("#iframe-report-print")[0].contentWindow.print() })

Hope it can help point you in the right direction

worthy7 avatar Sep 27 '19 08:09 worthy7

@dacster13 Hey Dexter, any contributions are welcome. The library code follows the style defined here: https://standardjs.com/ Run npm test after you are done making changes, it will show you of any style changes that may need be made before you commit.

About Firefox, the issue is because of their pdf.js implementation. There is a reported bug with mozilla: https://bugzilla.mozilla.org/show_bug.cgi?id=911444

The Mozilla bug was changed to closed for Firefox 75.0

Still doesn't seem to work with the examples at https://printjs.crabbly.com/ though (at least on Firefox 75.0 on Mac).

JonLaliberte avatar Apr 28 '20 19:04 JonLaliberte

Do you plan to add support for Edge? Thanks

drenda avatar May 22 '20 10:05 drenda

FYI: Version 1.2.0 now supports printing PDF files in Edge. The new package has been published to npm.

crabbly avatar Sep 14 '20 03:09 crabbly

FYI: Version 1.3.0 now supports printing PDF files in Firefox.

crabbly avatar Sep 17 '20 15:09 crabbly

@crabbly nice stuff!

niftylettuce avatar Oct 07 '20 16:10 niftylettuce