This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Journey To Enterprise Agility and have Daryl Kulak & Hong Li on-line!
See this thread for details.
Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Printing from an applet  RSS feed

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to print from an applet?
I can print using java print api from an application but service lookup fails in an applet?

As a matter of fact
PrintService printService = PrintServiceLookup.lookupDefaultPrintService();
returns null.



If it is possible can anybody give me a sample of working code?

Regards
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java specifies that it is a security violation to print from a regular (untrusted) applet, just as it is a security violation to read or write files on the user's machine. As a result, Java will automatically prompt the user with "An applet would like to print. Is this OK?", so the user can say "yes" or "no". In order to print from an applet without this prompt, you need to "sign" your applet or set up the security policy on the user's machine to grant your applet the printing privilege.
 
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it is difficult to print from an applet and should be avoided whenever possible, if there is any other way to do what you are trying to do, i sugest you do it that way, instead of printing through the applet.
 
Me
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by tommy k. lee:
"An applet would like to print. Is this OK?" ...



Even if, I get this message for printing from unsigned applets that will be fine. But I could never get even this message.
 
Bartender
Posts: 9509
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to the documentation for javax.print.PrintServiceLookup, an applet must be signed before it can print:


A PrintServiceLookup implementor is recommended to check for the SecurityManager.checkPrintJobAccess() to deny access to untrusted code. Following this recommended policy means that untrusted code may not be able to locate any print services. Downloaded applets are the most common example of untrusted code.

 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!