Package javax.print

Examples of javax.print.DocPrintJob


        }
    }
       
    public void print(Doc doc, String jobName) throws PrintException {
        // we need create a new job for each print
        DocPrintJob job = getPrintService().createPrintJob();
        PrintRequestAttributeSet attrs = new HashPrintRequestAttributeSet(printRequestAttributeSet);
        attrs.add(new JobName(jobName, Locale.getDefault()));
        job.print(doc, attrs);
    }
View Full Code Here


        boolean res2 = PrintServiceLookup.registerService(ps2);
        assertTrue("PrintService #2 should be registered.", res2);
        PrintService[] pss = PrintServiceLookup.lookupPrintServices(null, null);
        assertEquals("lookup should report two PrintServices.", numberOfPrintservicesBefore + 2, pss.length);

        DocPrintJob job1 = mock(DocPrintJob.class);
        when(ps1.createPrintJob()).thenReturn(job1);

        context.addRoutes(new RouteBuilder() {

            public void configure() {
View Full Code Here

        PrintService ps1 = mock(PrintService.class);
        when(ps1.getName()).thenReturn("MyPrinter\\\\remote\\printer1");
        when(ps1.isDocFlavorSupported(any(DocFlavor.class))).thenReturn(Boolean.TRUE);
        boolean res1 = PrintServiceLookup.registerService(ps1);
        assertTrue("The Remote PrintService #1 should be registered.", res1);
        DocPrintJob job1 = mock(DocPrintJob.class);
        when(ps1.createPrintJob()).thenReturn(job1);

        context.addRoutes(new RouteBuilder() {

            public void configure() {
View Full Code Here

        when(psDefault.getName()).thenReturn("DefaultPrinter");
        when(psDefault.isDocFlavorSupported(any(DocFlavor.class))).thenReturn(Boolean.TRUE);
        PrintServiceLookup psLookup = mock(PrintServiceLookup.class);
        when(psLookup.getPrintServices()).thenReturn(new PrintService[]{psDefault});
        when(psLookup.getDefaultPrintService()).thenReturn(psDefault);
        DocPrintJob docPrintJob = mock(DocPrintJob.class);
        when(psDefault.createPrintJob()).thenReturn(docPrintJob);
        MediaTray[] trays = new MediaTray[]{
            MediaTray.TOP,
            MediaTray.MIDDLE,
            MediaTray.BOTTOM
View Full Code Here

                PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
                aset.add(OrientationRequested.PORTRAIT);
                aset.add(new JobName(AppLocal.APP_NAME + " - Document", null));
                aset.add(media);

                DocPrintJob printjob = ps.createPrintJob();
                Doc doc = new SimpleDoc(new PrintableBasicTicket(m_ticketcurrent, imageable_x, imageable_y, imageable_width, imageable_height), DocFlavor.SERVICE_FORMATTED.PRINTABLE, null);

                printjob.print(doc, aset);
            }

        } catch (PrintException ex) {
            logger.log(Level.WARNING, AppLocal.getIntString("message.printererror"), ex);
            JMessageDialog.showMessage(parent, new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.printererror"), ex));
View Full Code Here

        //aset.add(MediaSize.A4);
        aset.add(Sides.ONE_SIDED);
       
        PrintService[] services = PrintServiceLookup.lookupPrintServices(docFlavor, aset);
        if (services.length > 0) {
          DocPrintJob job = services[0].createPrintJob();
            try {
              job.print(myDoc, aset);
            } catch (PrintException pe) {
                String errMsg = "Unable to print PDF from XSL-FO: " + pe.toString();
                Debug.logError(pe, errMsg, module);
                return ServiceUtil.returnError(errMsg);
            }
View Full Code Here

                }
            }
            if (UtilValidate.isNotEmpty(printer)) {
                PrintRequestAttributeSet praset = new HashPrintRequestAttributeSet();
                praset.add(new Copies(1));
                DocPrintJob job = printer.createPrintJob();
                job.print(myDoc, praset);
            } else {
                String errMsg = "No printer found with name: " + printerName;
                Debug.logError(errMsg, module);
                return ServiceUtil.returnError(errMsg);
            }
View Full Code Here

        }
    }
       
    public void print(Doc doc, String jobName) throws PrintException {
        // we need create a new job for each print
        DocPrintJob job = getPrintService().createPrintJob();
        PrintRequestAttributeSet attrs = new HashPrintRequestAttributeSet(printRequestAttributeSet);
        attrs.add(new JobName(jobName, Locale.getDefault()));
        job.print(doc, attrs);
    }
View Full Code Here

            public void onOkAnsware() {
                try {
                    DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
                    PrintService service = PrintServiceLookup.lookupDefaultPrintService();
                    Doc simple_doc = new SimpleDoc(makeAccountsInputStreamPrinting(), flavor, null);
                    DocPrintJob job = service.createPrintJob();
                    job.print(simple_doc, null);
                } catch (Exception exc) {
                    showWarningPrint(exc);
                }
            }
View Full Code Here

            public void onOk() {
                try {
                    DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
                    PrintService service = PrintServiceLookup.lookupDefaultPrintService();
                    Doc simple_doc = new SimpleDoc(makeAccountsInputStreamPrinting(), flavor, null);
                    DocPrintJob job = service.createPrintJob();
                    job.print(simple_doc, null);
                } catch (Exception exc) {
                    showWarningPrint(exc);
                }
            }
View Full Code Here

TOP

Related Classes of javax.print.DocPrintJob

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.