[thelist] How can I generate a printable page froma any web page (CSS, ASP?) Also - An Idea

James Aylard evolt at equilon-mrc.com
Thu Apr 12 12:22:03 CDT 2001


Jay,

> OK fellow gurus, one of the execs in my office just walked in and asked,
> "Can anyone visiting our site print any page on the site without all of
> those annoying graphics?" Is there a way to do this witout having to
create
> "printer-friendly" pages? I have searched but cannot find a how-to model
for
> this and I have a lot of other stuff on my plate (especially the backend
> database redesign where some have not heard the phrase "fully qualified
> names" much less names that make any sense at all for tables/columns),
> therefore I am looking for a fairly rapid solution.


    Yes, there are a couple of ways to do this. The most universally
compatible would be to dynamically generate a print-oriented page of just
the text server-side. This approach assumes that your text content is either
in a database or in separate include files, and can easily be plugged into a
separate print-oriented "template" page. (IMO, washingtonpost.com [1] does a
very good job with this approach.) If your pages are flat html, this would
not be a good option.
    A client-side approach to this is to use CSS to provide a different
style sheet for print media, e.g.:

<link rel="stylesheet"
   type="text/css"
   href="style.css"
   media="print">

OR

<style type="text/css" media="print">
   <!--
      /* print-oriented CSS style rules go here */
   // -->
</style>

OR

<style type="text/css">
   <!--
      @media print {
         body {
            background-color: #ffffff ;
            color: #000000 ;
         }
      }
      @media screen {
         body {
            background-color: #000000 ;
            color: #ffffff ;
         }
      }
   // -->
</style>

    However, browser support for each of these methods is mixed (although I
have listed them in order of greater support at the top to lesser support at
the bottom). For instance, Netscape 4.x will not support any of these
options. Also, you will have to do some tricks to remove images, such as set
the "display" property to "none" for img element, or to do so selectively on
certain images.

James Aylard
1. http://www.washingtonpost.com/





More information about the thelist mailing list