Solved

Printing table background colors

Posted on 2006-06-29
18
7,412 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 96

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
Industry Leaders: 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!

 
LVL 96

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 96

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
 
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 96

Author Comment

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

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 96

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
JavaScript Loan Calculator Error 3 47
Google Tag Manager - Add Trigger Using Div class 22 98
HTML5 storage and web apps 11 109
Pass a js value to an html form 5 42
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

732 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