Print.js
Print.js copied to clipboard
Browser support
What browsers and version are supported?
@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
Can we, by any chance write automated tests to test browser support?
Great idea. A quick search brought me to this: https://www.browserstack.com/javascript-testing-api
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.
It prints PDF in IE 11 when using Windows 7 SP1
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 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
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.
@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.
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.
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.
Am using chrome 62. Any idea why why its opening pdf instead of silent printing?
@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
print with json data doesn't work in chrome Version 65, just open a bland print preview
Hey @felixmayeya , Which OS and version?
macOS High Sierra, version 10.13.3 @crabbly
Yeah, prinjs don’t work on las version of chrome (leased yersteday). On both OS (windows and OS X)
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.
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).
Any news on this? Libraries like PDFjs manage to print in Edge or IE so it should be possible.
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.
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.
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
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
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.
@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
@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).
Do you plan to add support for Edge? Thanks
FYI: Version 1.2.0 now supports printing PDF files in Edge. The new package has been published to npm.
FYI: Version 1.3.0 now supports printing PDF files in Firefox.
@crabbly nice stuff!