http://qs321.pair.com?node_id=117572


in reply to Printer Friendly Pages

I have developed a "printer friendly" option on pages generated by scripts. In my case, I used EmbPerl on the server, but I guess the principle is the same.

Place somewhere on the page a "printer friendly" link - and even put a printer icon next to it if you are super keen. The URL (or value in the "HREF" field) is the current URL, with a parm of "print=yes" appended to it. Now if you are already passing arguments, then you separate this with an ampersand, elsewise a ?.

Then, the server side script that generates the page looks for the presence of the "print=yes" parm. Then, when the html is being generated, select a CSS style sheet that is a "bare bones" format - no background image, no fancy colors, all that stuff. You can also have sone logic within the page generation script, such that if print is on, don't include other widgets, (including the "printer friendly" link), all that stuff.

What's that you say? Your aren't using style sheets at all? (deep sigh). Go to the back of the class. Now read all the material on the W3C page to understand why you should be.