Any special considerations for making printable version of page?

M

moondaddy

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.
 
S

Steven Cheng[MSFT]

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
 
M

moondaddy

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

Steven Cheng[MSFT]

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
 
S

Steven Cheng[MSFT]

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
 
M

moondaddy

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

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top