red phoenix wrote:
I want to realize print function in Struts,when click a button in jsp
page,it will print part of screen information in Printer. I know javascript:
window.print() can realize print function,but it don't fit me,because
window.print() will print all screen information.I know another method,it
will write information into Excel and then print it in Excel,but it don't
fit me too,because it don't print directly! I want to know how to realize
print function directly?

This isn't Struts-specific, it's a general web development question. You have plenty of options, but the two I'd suggest you look at first are as follows:

1) create a 'print media' CSS style sheet to control what's output when the page is printed. You can selectively remove parts of the page you don't want to include in the printed format, as well as alter presentation styles (font, etc) to achieve the look you want. This has the advantage that the user will get the same result using their browser's default 'print' function, or hitting your Javascript print button.

2) if you need the printed output to be more substantially different than the on-screen format -- you need a completely different layout, or even different data, in the printed version, for example -- then you probably want to create two seperate pages, one for the on-screen view and one for the print view, then have a button in the on-screen view that will bring up the print-view.

Option 1 is by far the better approach IMHO, provided the differences between your on-screen and print-format data aren't beyond what can be achieved with CSS.

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to