Page view counter

Implementing 'printer-friendly version' page

Last post 07-09-2007 2:41 PM by mxitiup. 4 replies.

Sort Posts:

  • Implementing 'printer-friendly version' page

    07-09-2007, 1:38 PM
    • Loading...
    • mxitiup
    • Joined on 01-25-2007, 10:06 PM
    • Posts 38
    • Points 5

    Hi,

    I am working on making the "printer-friendly" function consistent across our application. Every page has a printer-friendly link at the top. In some pages, the link is a hyperlink that posts back and assigns a different masterpage on postback. In some pages which has lot of Ajax and non-Ajax client side javascript, the link does not post back (because depending on user interaction the javascript might have changed some things on the page). It just turns off the display of all the unwanted elements. In some other pages which has table display, it uses dataset cache to rebuild the table and display a printer friendly version. So this is what I am thinking of: on link-click, screen scrape the current page into a string, pop-up a new window, parse the string and remove header, footer, menu etc, display the resulting string in the new window. Will this work? Or is there a better way to accompolish the same? Any suggestions?

    Thanks.

     

  • Re: Implementing 'printer-friendly version' page

    07-09-2007, 2:25 PM
    • Loading...
    • rmaiya
    • Joined on 06-25-2007, 11:08 PM
    • Olympia, WA
    • Posts 1,559
    • Points 10,050

    The easiest way to achieve this is by creating another style sheet for printing only. and mention that in your header

    like this

    <head> 

    <link rel="stylesheet" type="text/css" media="screen" href="CSS/main.css" /> 

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

    Raghu
    (MCSD.NET, MCAD.NET, MCDBA)
    [Don't forget to click on Mark as answer on the post that helped you ]
  • Re: Implementing 'printer-friendly version' page

    07-09-2007, 2:27 PM
    • Loading...
    • rmarrs
    • Joined on 10-14-2005, 4:25 AM
    • Detroit, MI
    • Posts 52
    • Points 320

     A much cleaner way of doing this is creating a css for media type of print.  In other words, take your existing CSS document, and copy it.  Remove (you can set to visibility to hidden) anything you don't want to print  (advertisements, headers, footers, menus, whatever).  Set the Media property in your <link href="./linktoprint.css" media="print"/>.

     
    Then when a user clicks the print button, you can just have it call a javascript print method.  That way you don't need to  worry about parsing out a ton of data.

    Please: Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post solved your issue.
  • Re: Implementing 'printer-friendly version' page

    07-09-2007, 2:37 PM
    • Loading...
    • mxitiup
    • Joined on 01-25-2007, 10:06 PM
    • Posts 38
    • Points 5

    Hi,

    The requirement is to pop-up a new window for the printer-friendly version.


  • Re: Implementing 'printer-friendly version' page

    07-09-2007, 2:41 PM
    • Loading...
    • mxitiup
    • Joined on 01-25-2007, 10:06 PM
    • Posts 38
    • Points 5

    If I override the render method and capture the html string (http://west-wind.com/weblog/posts/481.aspx) that will be rendered to the user, what is the best way to pass this string to the pop-up page, say printerfriendly.aspx? I am thinking of creating this one page, and whenever the print link is clicked on any page, pass the html string to this printerfriendly.aspx page. ???

    And when an Ajax callback occurs, does it bypass render method?

    Thanks. 

Page 1 of 1 (5 items)