use of javax.print.attribute.Attribute in project adempiere by adempiere.
the class PrintUtil method testPS.
// dump
/*************************************************************************/
/**
* Test Print Services
*/
private static void testPS() {
PrintService ps = getDefaultPrintService();
ServiceUIFactory factory = ps.getServiceUIFactory();
System.out.println(factory);
if (factory != null) {
System.out.println("Factory");
JPanel p0 = (JPanel) factory.getUI(ServiceUIFactory.ABOUT_UIROLE, ServiceUIFactory.JDIALOG_UI);
p0.setVisible(true);
JPanel p1 = (JPanel) factory.getUI(ServiceUIFactory.ADMIN_UIROLE, ServiceUIFactory.JDIALOG_UI);
p1.setVisible(true);
JPanel p2 = (JPanel) factory.getUI(ServiceUIFactory.MAIN_UIROLE, ServiceUIFactory.JDIALOG_UI);
p2.setVisible(true);
}
System.out.println("1----------");
PrinterJob pj = PrinterJob.getPrinterJob();
PrintRequestAttributeSet pratts = getDefaultPrintRequestAttributes();
// Page Dialog
PageFormat pf = pj.pageDialog(pratts);
System.out.println("Pratts Size = " + pratts.size());
Attribute[] atts = pratts.toArray();
for (int i = 0; i < atts.length; i++) System.out.println(atts[i].getName() + " = " + atts[i] + " - " + atts[i].getCategory());
System.out.println("PageFormat h=" + pf.getHeight() + ",w=" + pf.getWidth() + " - x=" + pf.getImageableX() + ",y=" + pf.getImageableY() + " - ih=" + pf.getImageableHeight() + ",iw=" + pf.getImageableWidth() + " - Orient=" + pf.getOrientation());
ps = pj.getPrintService();
System.out.println("PrintService = " + ps.getName());
// Print Dialog
System.out.println("2----------");
pj.printDialog(pratts);
System.out.println("Pratts Size = " + pratts.size());
atts = pratts.toArray();
for (int i = 0; i < atts.length; i++) System.out.println(atts[i].getName() + " = " + atts[i] + " - " + atts[i].getCategory());
pf = pj.defaultPage();
System.out.println("PageFormat h=" + pf.getHeight() + ",w=" + pf.getWidth() + " - x=" + pf.getImageableX() + ",y=" + pf.getImageableY() + " - ih=" + pf.getImageableHeight() + ",iw=" + pf.getImageableWidth() + " - Orient=" + pf.getOrientation());
ps = pj.getPrintService();
System.out.println("PrintService= " + ps.getName());
System.out.println("3----------");
try {
pj.setPrintService(ps);
} catch (PrinterException pe) {
System.out.println(pe);
}
pf = pj.validatePage(pf);
System.out.println("PageFormat h=" + pf.getHeight() + ",w=" + pf.getWidth() + " - x=" + pf.getImageableX() + ",y=" + pf.getImageableY() + " - ih=" + pf.getImageableHeight() + ",iw=" + pf.getImageableWidth() + " - Orient=" + pf.getOrientation());
ps = pj.getPrintService();
System.out.println("PrintService= " + ps.getName());
System.out.println("4----------");
pj.printDialog();
}
Aggregations