Skip to main content

How to get a PrinterState

No replies
stewert
Offline
Joined: 2011-02-22
Points: 0

Hi,

I'm not to be able to get the PrinterState of my Printers. I have tested the following code on Linux and on Windows (7) with different Printers (Samsung, Brother (only on Linux), Zebra, ...). But in every case the PrinterState and the PrinterStateReasons objects are null.

private void dumpPrinterState() {
  PrintService[] printServices = PrintServiceLookup.lookupPrintServices(null, null); //get printers

  for (PrintService printService : printServices) {
    log.info("---- printer: " + printService);
    log.info("---- state: " + printService.getAttribute(PrinterState.class));
    log.info("---- reason: " + printService.getAttribute(PrinterStateReasons.class));
  }
}

Here is the output with my try on Windows:

---- printer: Win32 Printer : ZDesigner KR403
---- state: null
---- reason: null
---- printer: Win32 Printer : Samsung CLP-300 Series
---- state: null
---- reason: null
---- printer: Win32 Printer : Microsoft XPS Document Writer
---- state: null
---- reason: null
---- printer: Win32 Printer : Fax
---- state: null
---- reason: null

Anybody knows whats wrong?

Thanks,
Steffen