Matthew Pirritano
2022-Dec-17 00:20 UTC
[R] datatable using dt not able to print background colors
Hey, all! I've got a report that uses datatable from DT to create an rmarkdown html that looks great as an html but when I try to print it, to a printer, or to a pdf the colors I've assigned to cells are not displaying. I'm using chrome and I've clicked on the Background graphics button there, but that doesn't help print the colors. I have tried to run the datatable section of the code using results = 'asis' and eliminating results = 'asis'. Neither seems to help with the My css style at the top of the rmarkdown is <style type="text/css"> .main-container { max-width: 1500px; margin-left: auto; margin-right: auto; table.display td { white-space: wrap; } } td{ -webkit-print-color-adjust:exact !important; print-color-adjust:exact !important; } </style> I added the webkit bit based on what I've found online. Maybe I have something set up incorrectly there? Any ideas or thoughts on how to get this to print the background colors? Thanks matt ________________________________ This communication is intended for the use of the individual or entity to which it is addressed and may contain information that is privileged, confidential or otherwise exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify the sender and delete any copies. Thank you. [[alternative HTML version deleted]]
CALUM POLWART
2022-Dec-17 08:27 UTC
[R] datatable using dt not able to print background colors
I don't think this is an R issue, it's a HTML tables issue // browser issue. There are some hacks using background image (not R specific). BUT before you do any of this... Consider if colour is your answer! 8% of males are colour blind, so your table isn't as accessible as you may think it is. That's before you get to people who print in B&W etc On Sat, 17 Dec 2022, 00:21 Matthew Pirritano, <MPirritano at lacare.org> wrote:> Hey, all! > > I've got a report that uses datatable from DT to create an rmarkdown html > that looks great as an html but when I try to print it, to a printer, or to > a pdf the colors I've assigned to cells are not displaying. I'm using > chrome and I've clicked on the Background graphics button there, but that > doesn't help print the colors. I have tried to run the datatable section of > the code using results = 'asis' and eliminating results = 'asis'. Neither > seems to help with the > > My css style at the top of the rmarkdown is > > <style type="text/css"> > .main-container { > max-width: 1500px; > margin-left: auto; > margin-right: auto; > table.display td { white-space: wrap; } > > } > td{ > -webkit-print-color-adjust:exact !important; > print-color-adjust:exact !important; > } > </style> > > I added the webkit bit based on what I've found online. Maybe I have > something set up incorrectly there? Any ideas or thoughts on how to get > this to print the background colors? > > Thanks > matt > > > > > ________________________________ > > This communication is intended for the use of the individual or entity to > which it is addressed and may contain information that is privileged, > confidential or otherwise exempt from disclosure under applicable law. If > you are not the intended recipient, you are hereby notified that any > dissemination, distribution or copying of this communication is strictly > prohibited. If you have received this communication in error, please notify > the sender and delete any copies. Thank you. > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
Valentin Petzel
2022-Dec-17 15:12 UTC
[R] datatable using dt not able to print background colors
Hello Matt, I do not think that this is the best place for troubleshooting Chrome issues. If your html file shows the colors but print doesn't then the page probably uses different stylesheets for display and print. You might want to inspect the html for something like this. If you need help, the answers to this should get you there: https://superuser.com/questions/456700/how-do-i-print-with-the-screen-stylesheet Regards, Valentin 17.12.2022 01:21:25 Matthew Pirritano <MPirritano at lacare.org>:> Hey, all! > > I've got a report that uses datatable from DT to create an rmarkdown html that looks great as an html but when I try to print it, to a printer, or to a pdf the colors I've assigned to cells are not displaying. I'm using chrome and I've clicked on the Background graphics button there, but that doesn't help print the colors. I have tried to run the datatable section of the code using results = 'asis' and eliminating results = 'asis'. Neither seems to help with the > > My css style at the top of the rmarkdown is > > <style type="text/css"> > .main-container { > ? max-width: 1500px; > ? margin-left: auto; > ? margin-right: auto; > ? table.display td { white-space: wrap; } > > } > td{ > ? -webkit-print-color-adjust:exact !important; > ? print-color-adjust:exact !important; > } > </style> > > I added the webkit bit based on what I've found online. Maybe I have something set up incorrectly there? Any ideas or thoughts on how to get this to print the background colors? > > Thanks > matt > > > > > ________________________________ > > This communication is intended for the use of the individual or entity to which it is addressed and may contain information that is privileged, confidential or otherwise exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify the sender and delete any copies. Thank you. > > ? [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.