Printing Background Colors
Today we ran into an interesting problem here at work that some people may have already come across. Our goal was to print out a gant chart that we are dynamically generating. From a screen standpoint everything was looking great however when we went to print chart the color coding was gone. There are anywhere from 10-50 different colors on this chart so color printing was absolutely a requirement. So what was happening to the colors, in short nothing. In the browser (client is using IE) if you go to Tools > Internet Options > Advanced there is a printing option to print background colors and images. This by default was not checked. In short you could check this and solve all your problems. This was not an option for us to give to our customer so we began to digg deeper.
After looking around and seeking advice from the cf-talk mailing list I found my answers using CFDOCUMENT. This tag has an option of flashpaper which turns out has its own printing mechanism. With its own printing capabilities we do not have to relay on the browser to handle this. In the end this is exactly the solution we were looking for. From the flashpaper the client can click the print button and all of the background colors get printed out. While we are still working on some formatting and scaling issues I am sure we found the right answer. Here is a little code snippet so you can test it on your own. Thanks goes out to Todd Sharp and everyone on the cf-talk mailing list for all of their help coming up with a bunch of options to try.
<html>
<head>
<title>Background Color Printing Test</title>
</head>
<body>
<table>
<cfloop from="1" to="10" index="i">
<tr style="background-color:<cfif i mod 2>#ccc;<cfelse>#fff;</cfif>">
<td><cfoutput>#i#</cfoutput></td>
</tr>
</cfloop>
</table>
</body>
</html>
</cfdocument>
