[R] datatable using dt not able to print background colors

Valentin Petzel v@|ent|n @end|ng |rom petze|@@t
Sat Dec 17 16:12:31 CET 2022


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 using 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 using 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.



More information about the R-help mailing list