Printing tables with backgrounds

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
vivekjain
Forum Commoner
Posts: 76
Joined: Thu Jan 08, 2004 12:38 am

Printing tables with backgrounds

Post by vivekjain »

Hi,

I am not sure if this is the place for me to post this question, but am trying my luck.
I try printing a html <Table> with a background color, but then it only prints the text within the table and not the background image. There is a setting in the IE, but then cant expect all the users to do this. Is there a way to do this?

Thanks
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

If you've set a background colour for the cells in that table, their background colour will appear over top the background of the table.

Also, I'm moving this to Client Side.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
vivekjain
Forum Commoner
Posts: 76
Joined: Thu Jan 08, 2004 12:38 am

Printing tables with backgrounds

Post by vivekjain »

No, none of the cells have a bg color. It actually is a setting in IE, Tools-> Internet Options - >Advanced -> Print bg color. But I dont expect all the users to make this setting. Is there anyway that this background img printing can happen by defualt?

Thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

nope
User avatar
wwwapu
Forum Contributor
Posts: 197
Joined: Wed Apr 07, 2004 11:57 am
Location: Turku, Finland

Post by wwwapu »

You can use regular image to create background-color. It's easy if you only need one color for whole table and you know the dimensions and position of the table. Small example can be found at http://www.saunalahti.fi/jarzka/esimerk ... print.html

Develop a little further that idea and you can even color every other <tr>.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

You could..

Wrap the table in a div with 0 padding.
Make the table Transparent with 0 margin
Create a style sheet for print.

Code: Select all

<link rel="stylesheet" type="text/css" href="print.css" media="print" />
Assign the div a background image in the print.css style sheet
Test it.
vivekjain
Forum Commoner
Posts: 76
Joined: Thu Jan 08, 2004 12:38 am

Post by vivekjain »

Hi agtlewis,
I tried the steps you said, but it doesnt work.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

I'm surprised it didn't work. I figured it was worth a shot. It probably works in firefox.
Post Reply