diff --git a/src/qz/printer/PrintServiceMatcher.java b/src/qz/printer/PrintServiceMatcher.java index eb79b3262..813ba342c 100644 --- a/src/qz/printer/PrintServiceMatcher.java +++ b/src/qz/printer/PrintServiceMatcher.java @@ -55,7 +55,7 @@ public static NativePrinter getDefaultPrinter() { printers.putAll(defaultService); } - return printers.get(defaultService.getName()); + return printers.get(defaultService); } public static String findPrinterName(String query) throws JSONException { @@ -81,7 +81,7 @@ public static NativePrinter matchPrinter(String printerSearch, boolean silent) { if (!silent) { log.debug("Searching for PrintService matching {}", printerSearch); } NativePrinter defaultPrinter = getDefaultPrinter(); - if (printerSearch.equals(defaultPrinter.getName())) { + if (defaultPrinter != null && printerSearch.equals(defaultPrinter.getName())) { if (!silent) { log.debug("Matched default printer, skipping further search"); } return defaultPrinter; } diff --git a/src/qz/printer/info/NativePrinterMap.java b/src/qz/printer/info/NativePrinterMap.java index 2ab670407..15fb0db59 100644 --- a/src/qz/printer/info/NativePrinterMap.java +++ b/src/qz/printer/info/NativePrinterMap.java @@ -71,4 +71,13 @@ public boolean contains(PrintService service) { } return false; } + + public NativePrinter get(PrintService service) { + for (NativePrinter printer : values()) { + if (printer.getPrintService().equals(service)) { + return printer; + } + } + return null; + } }