March 22nd, 2003, 10:53 AM
Java: Print Button
The Java Print Service API added in SDK 1.4 has the following new packages:
I would like users to be able to print out a JSP internet page using a print button that functions the same way File > Print works. When a user presses the button, a print dialog would appear.
If I simply wanted to print the page without a print dialog, how would that work?
I do not want the print button itself to be a Swing component that requires an ActionListener. Do you have code for this or know where I can find a tutorial?
March 22nd, 2003, 12:57 PM
I doubt you can use java to print a web page. If you could you would have to have an applet on the page and the user would ahve to have the 1.4.1 plugin - at best.
You have to realize that jsp runs server side, and all the API's you have at your disposal are not available once the document reaches the client (browser). If you want to use java client side, you have to use an applet.
This will bring up the exact print dialog that a user gets when using File->Print.
<input type=button onclick="window.print()">