views:

455

answers:

2

Hello all,

Is there a JSP script I can run to point to a JPEG file on the local filesystem to be printed to the Windows default printer? Thanks.

Edit: I have the file on my server already. How would I load the file into a browser to run window.print()? Thanks

A: 

You would have to get them to upload the image to your server, then put the jpeg on a page with JavaScript to call window.print(). It's a security violation for webpages to just start reading the local filesystem.

Lou Franco
+2  A: 

You will need a java applet if you don't want a server round trip. The applet is required so that you can:

  1. Access the local file system.
  2. Access the printer natively.

The user will need to grant the applet privileges.

Be aware that printing from java is notoriously hard.

johnstok