How to know a printer is available?

Questions and answers for designing and implementing forms in Servoy

How to know a printer is available?

Postby e.valstar » Sun Jun 19, 2016 7:35 pm

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
e.valstar
 
Posts: 8
Joined: Mon Nov 17, 2014 9:52 pm

Re: How to know a printer is available?

Postby marco.rossi » Wed Feb 14, 2018 6:15 pm

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
Marco Rossi
Senior Analyst Developer
Freelance Consultant

IT Manager @Mantho
Webmaster @Sitoliquido
marco.rossi
 
Posts: 110
Joined: Sun Apr 12, 2015 9:33 pm


Return to Forms

Who is online

Users browsing this forum: No registered users and 3 guests