1

I'm using JNLP to print some images inside an applet. I pass a Printable object to a javax.jnlp.PrintService instance and call PrintService.print(). Is there any way to know when this operation completes?

Looking at line 116 of the PrintService source code, it seems to start a thread for printing and not attach anything to keep track of it.

There seems to be mechanisms for tracking print operations in other parts of Java, but I have not had success using other printing mechanisms in the context of a browser applet. (the user is constantly nagged about security)

Is it possible to print something in a signed java applet, not have the user be nagged about security, and know when the print operation finishes?

theycallmemorty
  • 12,515
  • 14
  • 51
  • 71
  • *" not have the user be nagged about security"* If 'asking once' is 'not being nagged', digitally sign the applet, get the user to accept it once at start-up, then print using the usual print services. – Andrew Thompson Jul 24 '12 at 23:25
  • @Andrew That is what I do currently, however I'm restricted to JNLP print services, no? – theycallmemorty Jul 25 '12 at 19:52
  • I left that for a while to see if I could make sense of it. I cannot. If an applet is trusted, it can use the [AWT printing API](http://docs.oracle.com/javase/7/docs/api/java/awt/print/package-frame.html), if is deployed uning JNLP and sand-boxed, it needs to use the `javax.jnlp.PrintService` for printing. Which is used in the code? – Andrew Thompson Jul 26 '12 at 03:43
  • @AndrewThompson We use JNLP for deploying the applet. – theycallmemorty Jul 26 '12 at 12:57
  • And the answer to my question would be, what? The code is using AWT or the `PrintService`? – Andrew Thompson Jul 26 '12 at 21:47
  • Thanks Andrew, I eventually got to the bottom of my problem. – theycallmemorty Aug 07 '12 at 17:55

1 Answers1

1

I managed to solve this problem by switching from using javax.jnlp.PrintService to using javax.print.PrintService. Using the later allows you to attach a PrintJobAdapter to monitor the status of the print job. See this Stack Overflow question.

All of this is perfectly acceptable in a JNLP deployed applet, provided the applet is signed.

Community
  • 1
  • 1
theycallmemorty
  • 12,515
  • 14
  • 51
  • 71