Page 1 of 1

How to know a printer is available?

PostPosted: Sun Jun 19, 2016 7:35 pm
by e.valstar
I want to print a form a use this code:
Code: Select all
   if (application.getPrinters().indexOf(printerName) >= 0) {
      forms.formName.controller.setPreferredPrinter(printerName);
      forms.formName.controller.print(true, false);
   }


When I'm connected to the network that have 'pinterName' it works fine.
But when it's not I got the error (only in the consol)

'Kan document niet afdrukken
> javax.print.PrintException: Printer is not accepting job.'

Seems logical to me, because the printer isn't available.
How can I test this printer is available. It tried it already with a try / catch method, but didn't work out.

Thanks on forehand

Re: How to know a printer is available?

PostPosted: Wed Feb 14, 2018 6:15 pm
by marco.rossi
Hi Valstart,

I see that this is an old post but when I faced this problem some years ago I did a plugin.
Look at https://docs.oracle.com/javase/7/docs/a ... State.html

Hope this help

Marco