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;
* 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);
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