#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    New Jersey
    Posts
    100
    Rep Power
    12

    Lightbulb Java: Print Button


    The Java Print Service API added in SDK 1.4 has the following new packages:

    javax.print
    javax.print.attribute
    javax.print.attribute.Standard
    javax.print.event

    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?

    Thanks,

    Robin
  2. #2
  3. No Profile Picture
    Clueless llama
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Feb 2001
    Location
    Lincoln, NE. USA
    Posts
    2,353
    Rep Power
    117
    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.

    Now, if you just want a button on a web page that initiates print, then you can use javascript.
    Code:
    <input type=button onclick="window.print()">
    This will bring up the exact print dialog that a user gets when using File->Print.

    Just to be thorough, do realize that java/jsp and javascript are not related.

IMN logo majestic logo threadwatch logo seochat tools logo