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..
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.
Joined: Jan 20, 2001
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.
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.
subject: printing from the client/browser using servlets on the server