From f9c38f2327222a45e9c278119ee2f691a79460cb Mon Sep 17 00:00:00 2001 From: tresf Date: Tue, 16 Jun 2020 11:53:34 -0400 Subject: [PATCH] Fix NPE for host printing Closes #672 --- src/qz/printer/PrintOptions.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/qz/printer/PrintOptions.java b/src/qz/printer/PrintOptions.java index 810f3e039..a73504114 100644 --- a/src/qz/printer/PrintOptions.java +++ b/src/qz/printer/PrintOptions.java @@ -19,6 +19,7 @@ import java.awt.print.PageFormat; import java.awt.print.PrinterException; import java.awt.print.PrinterJob; +import java.util.ArrayList; import java.util.List; import java.util.Locale; @@ -113,7 +114,8 @@ public PrintOptions(JSONObject configOpts, PrintOutput output, PrintingUtilities psOptions.density = asymmDPI.optInt("feed"); psOptions.crossDensity = asymmDPI.optInt("cross"); } else { - List rSupport = output.getNativePrinter().getResolutions(); + List rSupport = output.isSetService() ? + output.getNativePrinter().getResolutions() : new ArrayList<>(); JSONArray possibleDPIs = configOpts.optJSONArray("density"); if (possibleDPIs != null && possibleDPIs.length() > 0) {