wood burning stoves 2.0*
The moose likes Servlets and the fly likes printing from the client/browser using servlets on the server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "printing from the client/browser using servlets on the server" Watch "printing from the client/browser using servlets on the server" New topic
Author

printing from the client/browser using servlets on the server

sushil bajracharya
Greenhorn

Joined: Jan 20, 2001
Posts: 12
Problem Statement:
i need a facility inside a HTML page generated by some servlet or may be JSP which would allow the client to click an icon within the page and print certain parts of the page only in the printer.
The concept is actually similar to generating a customeized report. THe user gets a HTML page to view within the browser, and if he wants to print it then he has an option to print the page as a report. Actually the printing is to be done on a preformatted paper with ready-made headers and lines. A simple example might be viewing an invoice in the browser and having an option to print the contents of the invoice(HTML page) on a paper in the printer which has headers(company name , and standard lines and fields like Serial No. , Particulars, Qty, amount) already printed. The problem is the printer will be on clients computer, he'll have a standard paper with standard headers printed on it. We just need to fill the items under the header, the data to print will be same as in the HTML page the user is viewing.
How can a servlet control a printer attached to the clients computer?
Please reply..


java is great
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16158
    
  21

You can use the Java printing API. This allows you to format the pages anyway you like and not be tossed surprises by the user's browser. One caveat, though. Use of the printer is protected by the "sandbox". You'll have to build a signed applet.


Customer surveys are for companies who didn't pay proper attention to begin with.
sushil bajracharya
Greenhorn

Joined: Jan 20, 2001
Posts: 12
Thank you Tim for the reply..
I was just wandering if it is not possible to take control of the printer attached to the clients computer via a servlet as we take control of the browser the user is using to view the page.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16158
    
  21

Well, you can't really even take control of the browser - just pass it suggestions which must pass sandbox rules. Otherwise you'd be able to do the sort of rude things other products can - like shutting down the browser, saving files without the user's knowledge and permission, etc. That's where applet signing comes in. By providing a digital certificate of authenticity from a trusted source, you (and the certificate provider) are solemnly swearing not to do anything rude, crude, and socially unacceptible, in exchange for the right to do things above and beyond the usual sandbox limitations.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: printing from the client/browser using servlets on the server