• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Printing from an applet

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
When people don’t understand what you are doing they call you crazy. But this tiny ad just doesn't care:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic