thilino / jzebra

Automatically exported from code.google.com/p/jzebra
0 stars 0 forks source link

Find Default Printer and set print to default #66

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Would be helpful to be able to setPrinter() to the default printer on the 
client machine.  A possible function name:  setPrinterToDefault();

Current scenario:  I have several computers that may be attached to 3-4 zebra 
printers.  Would have the default printer set to the closest printer to 
computer, but will make a drop down to select another printer in case it was 
busy or in repair.  Would be nice to have a button to say "Select Default" that 
would reset the current printer to the computers default.  In jzebra list 
printers function, cannot determine which is default.  

Original issue reported on code.google.com by a2ro...@gmail.com on 30 May 2012 at 1:49

GoogleCodeExporter commented 8 years ago
According to "getPrinterJob()" documentation, the default printer is the 
default behavior.  If this is true, this would be a fairly quick code fix.

http://docs.oracle.com/javase/1.5.0/docs/api/java/awt/print/PrinterJob.html#getP
rinterJob()

-Tres

Original comment by tres.fin...@gmail.com on 30 May 2012 at 2:03

GoogleCodeExporter commented 8 years ago
Also, I come across this code

PrintService service =
                PrintServiceLookup.lookupDefaultPrintService();
        if (service != null) {
            String printServiceName = service.getName();
            System.out.println("Print Service Name = " + printServiceName);

That also returns the default

Original comment by a2ro...@gmail.com on 30 May 2012 at 2:12

GoogleCodeExporter commented 8 years ago
Good find.  Applied provided code to version 1.4.1.

Original comment by tres.fin...@gmail.com on 7 Jun 2012 at 1:53

GoogleCodeExporter commented 8 years ago
Download version 1.4.1 or higher and call findPrinter() with no parameters.  If 
a default printer is found, it will return it.

Accepting my own test results and closing as fixed since it's such a small bug. 
:)

-Tres

Original comment by tres.fin...@gmail.com on 7 Jun 2012 at 2:13