Solved

Printing table background colors

Posted on 2006-06-29
18
7,397 Views
Last Modified: 2011-08-18
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
Comment
Question by:Lee W, MVP
  • 6
  • 3
  • 3
  • +3
18 Comments
 
LVL 6

Accepted Solution

by:
pritaeas earned 250 total points
ID: 17012645
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
 
LVL 16

Assisted Solution

by:sam85281
sam85281 earned 200 total points
ID: 17012702
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
 
LVL 95

Author Comment

by:Lee W, MVP
ID: 17012715
I really hope that's not true.  Assuming for the moment it is - do you know how to set this in Firefox?
0
 
LVL 95

Author Comment

by:Lee W, MVP
ID: 17012744
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
 
LVL 16

Expert Comment

by:sam85281
ID: 17012759
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
 
LVL 30

Expert Comment

by:GrandSchtroumpf
ID: 17012778
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
 
LVL 95

Author Comment

by:Lee W, MVP
ID: 17012817
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
 
LVL 30

Expert Comment

by:GrandSchtroumpf
ID: 17012998
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 3

Assisted Solution

by:leos_
leos_ earned 50 total points
ID: 17015837
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
 
LVL 95

Author Comment

by:Lee W, MVP
ID: 17015851
Hmmm... I'll try that over the weekend (with luck) - thanks.
0
 
LVL 95

Author Comment

by:Lee W, MVP
ID: 17173998
Haven't forgotten about this - still need to check out a couple of the more recent suggestions.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 18011537
Assuming Leos_ is correct
0
 
LVL 30

Expert Comment

by:GrandSchtroumpf
ID: 18012890
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
 
LVL 95

Author Comment

by:Lee W, MVP
ID: 18013155
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
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 18013786
@GS: That is what I thought too, but I had no time to actually test it.
0
 
LVL 3

Expert Comment

by:leos_
ID: 18015681
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
 
LVL 3

Expert Comment

by:leos_
ID: 18015682
thanks for the assist in good faith.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction The Google Maps API offers various ways to draw dynamic and static maps.  Using a combination of PHP and JavaScript, you can draw active JavaScript maps that allow pan-and-zoom in the client browser window.  You can also draw "static" …
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now