Any special considerations for making printable version of page?

Discussion in 'ASP .Net' started by moondaddy, Apr 8, 2004.

  1. moondaddy

    moondaddy Guest

    I'm going to use an aspx page to display an invoice that customers can print
    from. Sometimes when I go to a site and navigate to a page I want to print,
    they will have a button that says something like "Show Printable Version".
    Other than taking out all of the gui stuff and making a simple clean page
    for printing, is there any other design considerations for making a page
    good for printing? I'm using frames and all of my content shows in the main
    frame. Is it possible to have the invoice aspx page show in the main frame
    and then just print that page and not the header and left menu frame?

    Thanks.

    --
    moondaddy, Apr 8, 2004
    #1
    1. Advertising

  2. Hi Moondaddy,

    From your description, you want to implement the printable page function
    which can help print a specify "printable" page. Also, your web application
    is frame based, so your problem is mainly focus on how to specify a certain
    frame to be printed, yes?

    As for this problem, I think you can use the following means:
    1. When in frame based page, we can use window.parent.frames("framename")
    to reference a certain frame we want. Then if we want a specified frame to
    be printed when we call "window.print()", we can use the "focus()" function
    of a window. For example, we have a three frames structure page.
    -----------------------------------------------
    top
    -----------------------------------------------
    left | right
    |
    |
    ---------------------------------------------------

    if we want to print the right frame when a button in left frame(in fact
    this applies no matter in which frame the function id called) is clicked:

    <script language="javascript">
    function printFrame(frm)
    {
    window.parent.frames(frm).focus();
    window.print();
    }
    </script>

    <input type="button" onclick="printFrame('right')" />

    #Notice that the key point is call the .focus() method which set the
    active frame(which will be printed when window.print() is called no matter
    in which frame).

    2. Also, I think you can also use the window.open( url of the printable
    page) or a hyperlink such as
    <a href="url of the printable page" target="_blank" />
    to open a new browser window which will contain the printable page. Do you
    think so?


    Regards,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    Get Preview at ASP.NET whidbey
    http://msdn.microsoft.com/asp.net/whidbey/default.aspx
    Steven Cheng[MSFT], Apr 8, 2004
    #2
    1. Advertising

  3. moondaddy

    moondaddy Guest

    Thanks. I wont be able to try this until tomorrow, but can you tell me what
    kind of browser compatibility this is?

    --

    "Steven Cheng[MSFT]" <> wrote in message
    news:...
    > Hi Moondaddy,
    >
    > From your description, you want to implement the printable page function
    > which can help print a specify "printable" page. Also, your web

    application
    > is frame based, so your problem is mainly focus on how to specify a

    certain
    > frame to be printed, yes?
    >
    > As for this problem, I think you can use the following means:
    > 1. When in frame based page, we can use window.parent.frames("framename")
    > to reference a certain frame we want. Then if we want a specified frame

    to
    > be printed when we call "window.print()", we can use the "focus()"

    function
    > of a window. For example, we have a three frames structure page.
    > -----------------------------------------------
    > top
    > -----------------------------------------------
    > left | right
    > |
    > |
    > ---------------------------------------------------
    >
    > if we want to print the right frame when a button in left frame(in fact
    > this applies no matter in which frame the function id called) is clicked:
    >
    > <script language="javascript">
    > function printFrame(frm)
    > {
    > window.parent.frames(frm).focus();
    > window.print();
    > }
    > </script>
    >
    > <input type="button" onclick="printFrame('right')" />
    >
    > #Notice that the key point is call the .focus() method which set the
    > active frame(which will be printed when window.print() is called no matter
    > in which frame).
    >
    > 2. Also, I think you can also use the window.open( url of the printable
    > page) or a hyperlink such as
    > <a href="url of the printable page" target="_blank" />
    > to open a new browser window which will contain the printable page. Do

    you
    > think so?
    >
    >
    > Regards,
    >
    > Steven Cheng
    > Microsoft Online Support
    >
    > Get Secure! www.microsoft.com/security
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    >
    > Get Preview at ASP.NET whidbey
    > http://msdn.microsoft.com/asp.net/whidbey/default.aspx
    >
    >
    >
    >
    moondaddy, Apr 13, 2004
    #3
  4. Hi Moondaddy,

    I've tested the code and find that it does have problem on browser
    compatability. I've only tested on IE6 and Mozilla1.6 and the behavior on
    window.print() is different from eachother.

    In IE6( I think IE5 is the same), the behavior is as I metioned in the last
    reply. We need to use
    window.parent.frames[index or id].focus(); to set the frame which we want
    to print and then
    call the window.print();

    However, in Mozilla, we can directory use
    window.parent.frames[index or id].print() to print the page in the
    specified frame.

    So I think if you don't want to be involved in the complex multi-browser
    managment, you can consider the other suggestion that use window.open or a
    hyper link to let the user open another browser window which contains the
    printable version page. Also, this is what many existing sites used. Do you
    think so?

    Regards,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    Get Preview at ASP.NET whidbey
    http://msdn.microsoft.com/asp.net/whidbey/default.aspx
    Steven Cheng[MSFT], Apr 13, 2004
    #4
  5. Hi Moondaddy,

    Have you had a chance to check out the suggestions in my last reply or have
    you got any further ideas on this issue? If you have anything unclear or if
    there're anything else we can help, please feel free to post here. Thanks.

    Regards,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)

    Get Preview at ASP.NET whidbey
    http://msdn.microsoft.com/asp.net/whidbey/default.aspx
    Steven Cheng[MSFT], Apr 15, 2004
    #5
  6. moondaddy

    moondaddy Guest

    Great thanks! This is good to know. I'll take your suggestion and use the
    window open.

    --

    "Steven Cheng[MSFT]" <> wrote in message
    news:...
    > Hi Moondaddy,
    >
    > I've tested the code and find that it does have problem on browser
    > compatability. I've only tested on IE6 and Mozilla1.6 and the behavior on
    > window.print() is different from eachother.
    >
    > In IE6( I think IE5 is the same), the behavior is as I metioned in the

    last
    > reply. We need to use
    > window.parent.frames[index or id].focus(); to set the frame which we want
    > to print and then
    > call the window.print();
    >
    > However, in Mozilla, we can directory use
    > window.parent.frames[index or id].print() to print the page in the
    > specified frame.
    >
    > So I think if you don't want to be involved in the complex multi-browser
    > managment, you can consider the other suggestion that use window.open or a
    > hyper link to let the user open another browser window which contains the
    > printable version page. Also, this is what many existing sites used. Do

    you
    > think so?
    >
    > Regards,
    >
    > Steven Cheng
    > Microsoft Online Support
    >
    > Get Secure! www.microsoft.com/security
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    >
    > Get Preview at ASP.NET whidbey
    > http://msdn.microsoft.com/asp.net/whidbey/default.aspx
    >
    moondaddy, Apr 15, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. RS

    Printable version

    RS, Feb 2, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    380
    Sonu Kapoor
    Feb 3, 2006
  2. Daniel Alexandre
    Replies:
    2
    Views:
    553
    Sibylle Koczian
    Mar 21, 2005
  3. Replies:
    2
    Views:
    353
  4. V Green
    Replies:
    0
    Views:
    826
    V Green
    Feb 5, 2008
  5. PA Bear [MS MVP]
    Replies:
    0
    Views:
    931
    PA Bear [MS MVP]
    Feb 5, 2008
Loading...

Share This Page