use of java.awt.print.PageFormat 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();
}
use of java.awt.print.PageFormat in project adempiere by adempiere.
the class PrintUtil method dump.
// getJobPriority
/*************************************************************************/
/**
* Dump Printer Job info
* @param job printer job
*/
public static void dump(PrinterJob job) {
StringBuffer sb = new StringBuffer(job.getJobName());
sb.append("/").append(job.getUserName()).append(" Service=").append(job.getPrintService().getName()).append(" Copies=").append(job.getCopies());
PageFormat pf = job.defaultPage();
sb.append(" DefaultPage ").append("x=").append(pf.getImageableX()).append(",y=").append(pf.getImageableY()).append(" w=").append(pf.getImageableWidth()).append(",h=").append(pf.getImageableHeight());
System.out.println(sb.toString());
}
Aggregations