Search in sources :

Example 26 with Attribute

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();
}
Also used : JPanel(javax.swing.JPanel) PageFormat(java.awt.print.PageFormat) Attribute(javax.print.attribute.Attribute) PrinterException(java.awt.print.PrinterException) PrintService(javax.print.PrintService) ServiceUIFactory(javax.print.ServiceUIFactory) PrinterJob(java.awt.print.PrinterJob) HashPrintRequestAttributeSet(javax.print.attribute.HashPrintRequestAttributeSet) PrintRequestAttributeSet(javax.print.attribute.PrintRequestAttributeSet)

Aggregations

Attribute (javax.print.attribute.Attribute)26 PrintServiceAttribute (javax.print.attribute.PrintServiceAttribute)13 PrintRequestAttribute (javax.print.attribute.PrintRequestAttribute)10 MediaSizeName (javax.print.attribute.standard.MediaSizeName)9 HashPrintRequestAttributeSet (javax.print.attribute.HashPrintRequestAttributeSet)8 JobName (javax.print.attribute.standard.JobName)8 HashPrintServiceAttributeSet (javax.print.attribute.HashPrintServiceAttributeSet)7 PrintRequestAttributeSet (javax.print.attribute.PrintRequestAttributeSet)7 PrintServiceAttributeSet (javax.print.attribute.PrintServiceAttributeSet)7 Fidelity (javax.print.attribute.standard.Fidelity)7 OrientationRequested (javax.print.attribute.standard.OrientationRequested)7 RequestingUserName (javax.print.attribute.standard.RequestingUserName)7 java.awt.print (java.awt.print)6 PrintJobAttribute (javax.print.attribute.PrintJobAttribute)6 Media (javax.print.attribute.standard.Media)6 File (java.io.File)5 IOException (java.io.IOException)5 URI (java.net.URI)5 Chromaticity (javax.print.attribute.standard.Chromaticity)5 Destination (javax.print.attribute.standard.Destination)5