From: Bill Erickson Date: Mon, 24 Feb 2014 16:49:01 +0000 (-0500) Subject: print debug option for testing X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=ec2f256b7537fa521341e322712675991b8c7ce4;p=working%2Frandom.git print debug option for testing Signed-off-by: Bill Erickson --- diff --git a/src/org/evergreen_ils/hatch/PrintDriver.java b/src/org/evergreen_ils/hatch/PrintDriver.java index 9dc2d85b8..c93ee3b7c 100644 --- a/src/org/evergreen_ils/hatch/PrintDriver.java +++ b/src/org/evergreen_ils/hatch/PrintDriver.java @@ -8,6 +8,11 @@ import java.awt.event.*; import javax.swing.*; import java.awt.print.*; +import javax.print.PrintService; +import javax.print.PrintServiceLookup; +import javax.print.attribute.Attribute; +import javax.print.attribute.AttributeSet; + public class PrintDriver implements Printable { private String printText; @@ -35,6 +40,7 @@ public class PrintDriver implements Printable { * Spawns standard JAVA-driven print dialog and prints text */ public boolean printWithDialog(String key, String text) { + debugPrintService(null); // testing printText = text; PrinterJob job = PrinterJob.getPrinterJob(); job.setPrintable(this); @@ -73,6 +79,24 @@ public class PrintDriver implements Printable { return true; } + private void debugPrintService(PrintService printer) { + + if (printer == null) { + printer = PrintServiceLookup.lookupDefaultPrintService(); + if (printer == null) { + logger.warn("No print service found in debugPrintService()"); + return; + } + } + + AttributeSet attributes = printer.getAttributes(); + for (Attribute a : attributes.toArray()) { + String name = a.getName(); + String value = attributes.get(a.getClass()).toString(); + logger.info("Printer Debug: " + name + " => " + value); + } + } + // experiment // show our own print dialog before the real print action takes over