How to detect if printer is not found

294 views
Skip to first unread message

Zoran Lazarevič

unread,
Jan 7, 2013, 4:12:10 AM1/7/13
to jzebra...@googlegroups.com
Hello!

I have problem detecting when printer is not found if you change printer between prints.
Steps to reproduce :
1. call findPrinter('HP') (printer HP exists)
2. when done finding jzebraDoneFinding() is called and I check if exception is null and printer is not null then its OK
3. then I call findPrinter('xxxx') and there is no such printer installed on machine
4. when done finding jzebraDoneFinding() is called and there is no exception but printer is still there but it is the old one

Is there a way to detetct that second printer is not found?

Environment :
jZebra 1.4.5
FF 17.0.1.
Java Plug-in 10.10.2.18
JRE version 1.7.0_10-b18 Java HotSpot(TM) Client VM

Here is the log from console - there is a warning in log, but I don't know how to use it.
jan 07, 2013 9:34:50 AM jzebra.LogIt log
INFO: jZebra 1.4.5
jan 07, 2013 9:34:50 AM jzebra.LogIt log
INFO: ===== JAVASCRIPT LISTENER THREAD STARTED =====
jan 07, 2013 9:34:59 AM jzebra.LogIt log
INFO: ===== SEARCHING FOR PRINTER =====
jan 07, 2013 9:35:00 AM jzebra.LogIt log
INFO: Found 5 attached printers.
jan 07, 2013 9:35:00 AM jzebra.LogIt log
INFO: Printer specified: \Qhp\E
jan 07, 2013 9:35:00 AM jzebra.LogIt log
INFO: Printer name match: \\ZOKI-PC\HP Photosmart C4100 series
jan 07, 2013 9:35:00 AM jzebra.LogIt log
INFO: Using best match: \\ZOKI-PC\HP Photosmart C4100 series
jan 07, 2013 9:35:06 AM jzebra.LogIt log
INFO: ===== SEARCHING FOR PRINTER =====
jan 07, 2013 9:35:06 AM jzebra.LogIt log
INFO: Found 5 attached printers.
jan 07, 2013 9:35:06 AM jzebra.LogIt log
INFO: Printer specified: \Qxxxx\E
jan 07, 2013 9:35:06 AM jzebra.LogIt log
WARNING: Printer not found: \Qxxxx\E
jan 07, 2013 9:35:06 AM jzebra.LogIt log
WARNING: Ignoring null PrintService


Best regards,
  Zoran

Tres Finocchiaro

unread,
Jan 7, 2013, 8:15:29 AM1/7/13
to jzebra...@googlegroups.com
Zoran,

The wiki page does not explain this well, but the best way to work with multiple printers is to use applet.getPrinters() and use your own code to iterate over them.

This works best after searching for a printer.  This example can be found in sample.html.

This has much room for improvement, so please file an enhancement request here if this is something you'd like improved on.

function findPrinters() {
         var applet = document.jzebra;
         if (applet != null) {
            // Searches for locally installed printer with "zebra" in the name
            applet.findPrinter("\\{dummy printer name for listing\\}");
         }
         monitorFinding2();
}
 function monitorFinding2() {
var applet = document.jzebra;
if (applet != null) {
  if (!applet.isDoneFinding()) {
     window.setTimeout('monitorFinding2()', 100);
  } else {
              var printersCSV = applet.getPrinters();
              var printers = printersCSV.split(",");
              for (p in printers) {
                  alert(printers[p]);
              }
              
  }
} else {
            alert("Applet not loaded!");
        }
      }

-Tres

--
To unsubscribe from this group, send email to jzebra-users...@googlegroups.com
 
http://code.google.com/p/jzebra



--
- Tres.Fin...@gmail.com

Zoran Lazarevič

unread,
Jan 7, 2013, 5:20:48 PM1/7/13
to jzebra...@googlegroups.com
Tres,

I will use applet.getPrinters() and check in list if printer exists.
Thank you for your qucik answer.

Best regards,
   Zoran

frend Carlo

unread,
Jan 25, 2013, 6:45:10 AM1/25/13
to jzebra...@googlegroups.com


On Monday, January 7, 2013 2:15:29 PM UTC+1, Tres Finocchiaro wrote:
Zoran,

The wiki page does not explain this well, but the best way to work with multiple printers is to use applet.getPrinters() and use your own code to iterate over them.

This works best after searching for a printer.  This example can be found in sample.html.
Hi, I don't know if I have the same problem as what he had, I use this applets for my web application. My Problem is how can I refresh a list of printers?

   here is the scenario:

   I run the sample.html program, then click List all printers, I have my list of printers correctly. Now, when I change the name of one of my printers, and then go back to sample.html and click again List all printers, the old printer name that I change is still there, How can I update the list so that the new printer name appears / detected?

thanks in advance


Carlo

Tres Finocchiaro

unread,
Jan 25, 2013, 8:57:43 AM1/25/13
to jzebra...@googlegroups.com
Zoran,

I have this same problem.  I'm not sure if it is caused by the code or if it is a limitation with jZebra.

Feel free to submit an enhancement request with this feature.

For now, you will have to instruct anyone adding and removing print devices mid-flight to close and re-open the web browser for the new printer to appear.  (Some browsers such as chrome allow you to simply close and reopen the tab).

-Tres

--
--
To unsubscribe from this group, send email to jzebra-users...@googlegroups.com
 
http://code.google.com/p/jzebra
 
 
 
Reply all
Reply to author
Forward
0 new messages