DWilliams Posted February 4, 2010 Share Posted February 4, 2010 I'm coding a reports system for work. It is mostly complete outside of various tinkering, but I have a slight issue. For visual appeal, each report row color is alternated, in other words, one row will be white, the next gray, and repeating like that. The problem here is that these reports are designed specifically to be printed and mailed out to our clients. Our workstations use Firefox, and by default, it does not print background colors, so when a user prints one of my reports it looks like endless amounts of text thrown at a page without the background colors to visually separate areas. I've worked around this problem by going around to each user's computer and enabling "print backgrounds" in their options, but this is hardly ideal. There's the obvious fact that anything requiring me to walk around to everyone's office is bad administration practice, but this also has the downside that EVERY background now prints for them, which is a pain when they try to print some text from a background heavy website. Is there any way for my scripts to signal that a background is necessary and SHOULD be printed? I assume that CSS is the way to do this if it is indeed possible. Quote Link to comment Share on other sites More sharing options...
haku Posted February 4, 2010 Share Posted February 4, 2010 I don't think this can be done through CSS. The reason being that generally, people don't state which media a particular CSS stylesheet is relevant for, and therefore the stylesheet becomes active for all media - including screen and printing. So if you are trying to print this and the background isn't printing, then the making any stylesheet changes isn't going to do anything that it isn't already doing. As such, if there is a way to do this, it will probably be a PHP solution, so I'm moving this thread to the php section of the forum. Good luck! Quote Link to comment Share on other sites More sharing options...
DWilliams Posted February 4, 2010 Author Share Posted February 4, 2010 Well the reason I figured CSS seemed like the likely solution is because it DOES have some control over how things are printed. I already have it set up so that different fonts are used for the report text when printed as opposed to being viewed on screen. CSS is the only thing I've ever seen that has any sort of server-side control over how a page is printed. Oh well, hopefully somebody has come across this before. It seems like a pretty common thing that someone would want their background color to be printed for a number of reasons. Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted February 4, 2010 Share Posted February 4, 2010 Trying to make professional reports in HTML and CSS is a fool's errand. There are libraries that can convert HTML and CSS into a PDF; you might look into that as a way of displaying the page. I use BIRT to create reports. Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted February 4, 2010 Share Posted February 4, 2010 printing from a browser will always ignore background images... If you think about it - printing a page out you are getting a hard copy of the information; that doesn't require any design aspect to it. Use a print sty;le sheet to layout a page so its more easily read on printing but don't try and print out a hi fidelity copy of your design - thats not what you need when reading something... The alternative as roopert says is to create a pdf which, if you MUST have the design aspect, will be the better option. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.