[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 7424
  • Last Modified:

Printing table background colors

I'm sure I can do this with CSS and NOT using tables at all, but I don't know CSS well enough to rewrite the page to have it look as I want it and I have something of a deadline.  So, that said, I have a table that alternates between light gray and white lines to help clarify each "item" on a report with no table borders.  When I print it, I want the light gray to show up.  Is there a way (possibly a style?) that I force the background color to print?

I'm not awarding points to anyone who says don't use tables unless they provide something that *I* consider a very easy solution without tables.
0
Lee W, MVP
Asked:
Lee W, MVP
  • 6
  • 3
  • 3
  • +3
3 Solutions
 
pritaeasSoftware EngineerCommented:
Printing the background color is a setting of your browser. I don't think you can turn it on with CSS if it is turned off in the preferences.
0
 
sam85281Commented:
There is no way to FORCE a user to print background colors.  If you need to do it for you...

In IE:
Go to Tools=>Internet Options=>Advanced Tab=>Scroll down to PRINTING and check "allow background...."

In FF/MOZ:
Go to File=>Page Setup=>Print Background.....

-Sam
0
 
Lee W, MVPTechnology and Business Process AdvisorAuthor Commented:
I really hope that's not true.  Assuming for the moment it is - do you know how to set this in Firefox?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Lee W, MVPTechnology and Business Process AdvisorAuthor Commented:
That will do folks.  I'm going to leave the question open a bit longer in hopes that someone knows a trick, but as I think about it, it makes sense that you can't force it.  I'll live with the manual setting if I must.  If that's all I get, you two will split an A grade.
0
 
sam85281Commented:
It IS true.  It's a security issue.  Nobody wants to go to a page and print not realizing that they're gonna use up ALL their ink/toner.

Firefox:
Go to File=>Page Setup=>Check the "Print Background(colors and images)" box

-Sam
0
 
GrandSchtroumpfCommented:
tables are not the issue here.

as already said, it's a browser setting... it's true.
unfortunately for you and for the ink manufacturers and resellers, but fortunately for everyone else.

for IE only, you might be able to force printing background colors using some ActiveX like this one:  http://www.meadroid.com/scriptx/freedep.asp
0
 
Lee W, MVPTechnology and Business Process AdvisorAuthor Commented:
I disagree - it's not a security issue - your security is not at risk - your supplies are, but not your security.  Again, I understand this now, the problem with this logic though is sometimes pictures are background pictures and other times they are not - it's sometimes quite difficult to tell when a background image will print and when it won't.  As I said, "as I think about it, it makes sense that you can't force it."
0
 
GrandSchtroumpfCommented:
note that borders always print.
they can be used as "background" using some CSS manipulation (negative margins for instance) so that your text overlaps the borders... but a perfect result cannot always be obtained.
also, it will add complexity to your page and some browsers might choke on it.
0
 
leos_Commented:
We ran into this issue building templates for real estate agents.  They wanted to be able to print the background colours all the time but the default browser setting doesn't print them.  We found if we used a 1x1 gif of the colour we wanted for the background it worked well.  To allow the user to change the background we used a dynamically created 1x1 pixel gif - which was actually pretty easy.

I recommend this.
<table>
 <tr style="background-image:red.gif"><td>col1</td><td>col2,</td></tr>
 <tr style="background-image:blue.gif"><td>col1</td><td>col2,</td></tr>
 <tr style="background-image:red.gif"><td>col1</td><td>col2,</td></tr>
 <tr style="background-image:blue.gif"><td>col1</td><td>col2,</td></tr>
etc.
</table>
0
 
Lee W, MVPTechnology and Business Process AdvisorAuthor Commented:
Hmmm... I'll try that over the weekend (with luck) - thanks.
0
 
Lee W, MVPTechnology and Business Process AdvisorAuthor Commented:
Haven't forgotten about this - still need to check out a couple of the more recent suggestions.
0
 
Michel PlungjanIT ExpertCommented:
Assuming Leos_ is correct
0
 
GrandSchtroumpfCommented:
I assume Leos_ is NOT correct.
In all the browser i know, printing background-colors and printing background-images is one and only one setting.
If the background-color does not print, the background-image should not print either.
0
 
Lee W, MVPTechnology and Business Process AdvisorAuthor Commented:
Here's the thing - I turned on the printing options in the browsers - which for me, was sufficient... I would have preferred a way (quite possibly leos_'s way) that didn't require any browser modifications, but I also know if there were, I'd be among the people screaming loudest because companies would undoubtedly abuse it.
0
 
Michel PlungjanIT ExpertCommented:
@GS: That is what I thought too, but I had no time to actually test it.
0
 
leos_Commented:
For ie 6.0 default printer options print background images but not background colours. Have not tested ie 7 yet.  I'm not 100% sure of other browers so I'm guessing mozilla users don't print or it works for them too. You can change your printing options will over ride this method, or allow it to work on any browser - we were interested in most browsers by default.
0
 
leos_Commented:
thanks for the assist in good faith.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 6
  • 3
  • 3
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now