print debug option for testing
authorBill Erickson <berick@esilibrary.com>
Mon, 24 Feb 2014 16:49:01 +0000 (11:49 -0500)
committerBill Erickson <berick@esilibrary.com>
Mon, 24 Feb 2014 16:49:01 +0000 (11:49 -0500)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
src/org/evergreen_ils/hatch/PrintDriver.java

index 9dc2d85..c93ee3b 100644 (file)
@@ -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