我无法获得打印机的PrinterState。我已经在Linux和Windows(7)上使用不同的打印机(三星,Brother(仅限Linux),Zebra,...)测试了以下代码。但在每种情况下,PrinterState和PrinterStateReasons对象都为空。
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));
}
}
以下是我在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
有人知道什么是错的吗?