• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to print contents of Applet-- Urgent

 
Suman bose
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Friend,
It's urgent!!. can you help me how to print contents of applet?
Thanks
Suman Bose
 
Tim Holloway
Saloon Keeper
Posts: 18367
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the java printing API.
You'll have to secure and sign the applet, though - printing is sandbox-protected. Otherwise evil applets could hog the printer, fill up the print queues and crash the print server, and so forth.
Usually it's easier to create the document to be printed on the webserver and have the user use the "print" menu option on the web browser. Informal printing can be done just by setting up the document to be printed as a web page. If you want more rigid control over fonts and layout, create a PDF document. There's an API you can pick up at http://www.sourceforge.net that's good for most purposes. It was originally known as retepPDF, but they have it listed as something like jpdfPrint now.
 
Ben Hodgson
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure about having to secure/sign the applet? I've used a Swing (J)Applet which prints the contents of a JPanel, and it's not signed. When I ask to print (by pressing a button) I get a dialogue which asks something along the lines of "An applet wants to print - is this okay?" and, answering yes, it prints fine.
There is a good example of how to print a component in Java2 in the O'Reilly Java Foundation Classes in a Nutshell.
 
Tim Holloway
Saloon Keeper
Posts: 18367
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Because the default behavior for Java applets and applications
running in restricted environments is no access to system resources,
all access to system resources such as file systems, networking
facilities, screens, keyboards, disk drives, and printers is not
allowed unless specifically granted. The restricted environments
also prevent communications between Java programs."
I got this from http://developer.java.sun.com/developer/technicalArticles/Security/ReallySecure/
A lot of confusion results from the fact that the AppletViewer and IDEs have looser sandbox rules than applets in web browsers. People develop these things and test them and are happy, then get clobbered when they try and put the applets into production.
Considering all the "Code Red" attempts that have been made on my servers, this month, however, I think I prefer Sun's idea of security to Microsoft's, though.
[This message has been edited by Tim Holloway (edited August 17, 2001).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic