Package javax.print

Examples of javax.print.DocPrintJob


    {
      throw new RuntimeException("print: required doc flavor is not supported");
    }
   
    //create print job
    DocPrintJob job = printService_.createPrintJob();

    //create the document to print
    byte[] bytes = printable.getBytes();
    InputStream is = new ByteArrayInputStream(bytes);
    DocAttributeSet docAttribs   = new HashDocAttributeSet();
    javax.print.Doc doc = new javax.print.SimpleDoc(is, flavor, docAttribs);
   
    try
    {
      PrintRequestAttributeSet printAttributes = new HashPrintRequestAttributeSet();
      job.print(doc, printAttributes);
    }
    catch (PrintException e)
    {
      throw new RuntimeException("print: fail to print the data. Error: " + e.getMessage());
    }
View Full Code Here


     */
    public void printFO(File fo)
            throws IOException, FOPException, TransformerException, PrintException {

        //Set up DocPrintJob instance
        DocPrintJob printJob = createDocPrintJob();

        //Set up a custom user agent so we can supply our own renderer instance
        FOUserAgent userAgent = fopFactory.newFOUserAgent();

        PageableRenderer renderer = new PageableRenderer();
        renderer.setUserAgent(userAgent);
        userAgent.setRendererOverride(renderer);

        // Construct FOP with desired output format
        Fop fop = fopFactory.newFop(userAgent);

        // Setup JAXP using identity transformer
        TransformerFactory factory = TransformerFactory.newInstance();
        Transformer transformer = factory.newTransformer(); // identity transformer

        // Setup input stream
        Source src = new StreamSource(fo);

        // Resulting SAX events (the generated FO) must be piped through to FOP
        Result res = new SAXResult(fop.getDefaultHandler());

        // Start XSLT transformation and FOP processing
        transformer.transform(src, res);

        Doc doc = new SimpleDoc(renderer, DocFlavor.SERVICE_FORMATTED.PAGEABLE, null);
        printJob.print(doc, null);
    }
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

            }
            if (mark.length() > 15) {
                mark = mark.substring(0, 15);
            }
                       
            DocPrintJob job = psZebra.createPrintJob();
            String buff =
                "N\n" +
                header[0] + pixA[0] + "," + pixB[0] + ",0,1,1,1,N,\"Grupo Total 99 C.A.\"\n"+
                "A" + pixA[1] + ",15,0,1,1,1,N,\"RIF: J-31150187-8\"\n"+
                "A" + pixA[2] + ",40,0,4,1,2,N,\""+ price +"\"\n"+
                "A" + pixA[3] + ",45,0,4,1,1,N,\"Bs.\"\n"+
                //"A" + separations[4] + ",80,0,3,1,1,N,\""+mark+"\"\n"+
                "A" + pixA[5] + ",100,0,1,1,1,N,\""+description+"\"\n"+
                "A" + pixA[6] + ",115,0,1,1,1,N,\""+description2+"\"\n"+
                "A" + pixA[7] + ",140,0,1,1,1,N,\""+date + "\"\n"+
                "A" + pixA[8] + ",160,0,1,1,1,N,\""+barCode +"\"\n"+
                "A" + pixA[9] + ",180,0,1,1,1,N,\""+"AGENCIA " + Shared.getConfig("storeName") +"\"\n"+
                "B" + pixA[10] + ",130,0,1,1,2,100,N,\"" + barCode + "\"\n"+

                "A" + (offset+pixA[0]) +",0,0,1,1,1,N,\"Grupo Total 99 C.A.\"\n"+
                "A" + (offset+pixA[1]) + ",15,0,1,1,1,N,\"RIF: J-31150187-8\"\n"+
                "A" + (offset+pixA[2]) + ",40,0,4,1,2,N,\""+price +"\"\n"+
                "A" + (offset+pixA[3]) + ",45,0,4,1,1,N,\"Bs.\"\n"+
                //"A" + (offset+separations[4]) + ",80,0,3,1,1,N,\""+mark+"\"\n"+
                "A" + (offset+pixA[5]) + ",100,0,1,1,1,N,\""+description+"\"\n"+
                "A" + (offset+pixA[6]) + ",115,0,1,1,1,N,\""+description2+"\"\n"+
                "A" + (offset+pixA[7]) + ",140,0,1,1,1,N,\""+date + "\"\n"+
                "A" + (offset+pixA[8]) + ",160,0,1,1,1,N,\""+barCode +"\"\n"+
                "A" + (offset+pixA[9]) + ",180,0,1,1,1,N,\"" +"AGENCIA "  + Shared.getConfig("storeName") +"\"\n"+
                "B" + (offset+pixA[10]) + ",130,0,1,1,2,100,N,\"" + barCode + "\"\n"+
                "P" + firstLot + "\n";

            DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
            Doc doc = new SimpleDoc(buff.getBytes(), flavor, null);
            job.print(doc, null);
        } catch (PrintException ex) {
            MessageBox msb = new MessageBox(MessageBox.SGN_DANGER, "Problemas con la impresora.",ex);
            msb.show(Shared.getMyMainWindows());
        }
    }
View Full Code Here

        if (mark.length() > 15) {
            mark = mark.substring(0, 15);
        }

        try{
            DocPrintJob job = psZebra.createPrintJob();
            String buff =
                "N\n" +
                header[0] + pixA[0] + "," + pixB[0] + ",0,1,1,1,N,\"Grupo Total 99 C.A.\"\n"+
                "A" + pixA[1] + ",15,0,1,1,1,N,\"RIF: J-31150187-8\"\n"+
                "A" + pixA[2] + ",40,0,4,1,2,N,\""+ price +"\"\n"+
                "A" + pixA[3] + ",45,0,4,1,1,N,\"Bs.\"\n"+
                //"A" + separations[4] + ",80,0,3,1,1,N,\""+mark+"\"\n"+
                "A" + pixA[5] + ",100,0,1,1,1,N,\""+description+"\"\n"+
                "A" + pixA[6] + ",115,0,1,1,1,N,\""+description2+"\"\n"+
                "A" + pixA[7] + ",140,0,1,1,1,N,\""+date + "\"\n"+
                "A" + pixA[8] + ",160,0,1,1,1,N,\""+barCode +"\"\n"+
                "A" + pixA[9] + ",180,0,1,1,1,N,\"" +"AGENCIA "  + Shared.getConfig("storeName") +"\"\n"+
                "B" + pixA[10] + ",130,0,1,1,2,100,N,\"" + barCode + "\"\n"+
                "P1\n";

            DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
            Doc doc = new SimpleDoc(buff.getBytes(), flavor, null);
            job.print(doc, null);
        } catch (PrintException ex) {
            MessageBox msb = new MessageBox(MessageBox.SGN_DANGER, "Problemas con la impresora.",ex);
            msb.show(Shared.getMyMainWindows());
        }
View Full Code Here

        if (markB.length() > 15) {
            markB = markB.substring(0, 15);
        }

        try{
            DocPrintJob job = psZebra.createPrintJob();
            String buff =
                "N\n" +
                header[0] + pixA[0] + "," + pixB[0] + ",0,1,1,1,N,\"Grupo Total 99 C.A.\"\n"+
                "A" + pixA[1] + ",15,0,1,1,1,N,\"RIF: J-31150187-8\"\n"+
                "A" + pixA[2] + ",40,0,4,1,2,N,\""+ price +"\"\n"+
                "A" + pixA[3] + ",45,0,4,1,1,N,\"Bs.\"\n"+
                //"A" + separations[4] + ",80,0,3,1,1,N,\""+mark+"\"\n"+
                "A" + pixA[5] + ",100,0,1,1,1,N,\""+description+"\"\n"+
                "A" + pixA[6] + ",115,0,1,1,1,N,\""+description2+"\"\n"+
                "A" + pixA[7] + ",140,0,1,1,1,N,\""+date + "\"\n"+
                "A" + pixA[8] + ",160,0,1,1,1,N,\""+barCode +"\"\n"+
                "A" + pixA[9] + ",180,0,1,1,1,N,\"" +"AGENCIA "  +Shared.getConfig("storeName"+"\"\n"+
                "B" + pixA[10] + ",130,0,1,1,2,100,N,\"" + barCode + "\"\n"+

                "A" + (offset+pixA[0]) +",0,0,1,1,1,N,\"Grupo Total 99 C.A.\"\n"+
                "A" + (offset+pixA[1]) + ",15,0,1,1,1,N,\"RIF: J-31150187-8\"\n"+
                "A" + (offset+pixA[2]) + ",40,0,4,1,2,N,\""+priceB +"\"\n"+
                "A" + (offset+pixA[3]) + ",45,0,4,1,1,N,\"Bs.\"\n"+
                //"A" + (offset+separations[4]) + ",80,0,3,1,1,N,\""+mark+"\"\n"+
                "A" + (offset+pixA[5]) + ",100,0,1,1,1,N,\""+descriptionB+"\"\n"+
                "A" + (offset+pixA[6]) + ",115,0,1,1,1,N,\""+description2B+"\"\n"+
                "A" + (offset+pixA[7]) + ",140,0,1,1,1,N,\""+date + "\"\n"+
                "A" + (offset+pixA[8]) + ",160,0,1,1,1,N,\""+barCodeB +"\"\n"+
                "A" + (offset+pixA[9]) + ",180,0,1,1,1,N,\""+"AGENCIA " +Shared.getConfig("storeName"+"\"\n"+
                "B" + (offset+pixA[10]) + ",130,0,1,1,2,100,N,\"" + barCodeB + "\"\n"+
                "P1\n";

            DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
            Doc doc = new SimpleDoc(buff.getBytes(), flavor, null);
            job.print(doc, null);
        } catch (PrintException ex) {
            MessageBox msb = new MessageBox(MessageBox.SGN_DANGER, "Problemas con la impresora.",ex);
            msb.show(Shared.getMyMainWindows());
        }
    }
View Full Code Here

                for (Object pra : printRequestAttributes) {
                    Debug.logInfo("Adding PrintRequestAttribute: " + pra, module);
                    praset.add((PrintRequestAttribute) pra);
                }
            }
            DocPrintJob job = printer.createPrintJob();
            job.print(myDoc, praset);


        } catch (Exception e) {
            String errMsg = "Error rendering [" + contentType + "]: " + e.toString();
            Debug.logError(e, errMsg, module);
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

        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

        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);
        PrintServiceLookup.registerServiceProvider(psLookup);
    }
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.