Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: send image (logo) and text & barcode to the Zebra Printer

  1. #1
    Junior Member
    Join Date
    Aug 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default send image (logo) and text & barcode to the Zebra Printer

    hello dear
    i 'm need send image (logo) and text & barcode to the Zebra Printer in Java ?
    for example send logo zebra

    this code for send image (graphic object) not work ?
            try{
            System.out.println(" Zebra Print testing!");
            // Prepare date to print in dd/mm/yyyy format
            Date now = new Date();
            SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
            String dateString = format.format(now);
            // Search for an installed zebra printer...
            // is a printer with "zebra" in its name
            PrintService psZebra = null;
            String sPrinterName = null;
            PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null);
            for (int i = 0; i < services.length; i++) {
                PrintServiceAttribute attr = services[i].getAttribute(PrinterName.class);
                sPrinterName = ((PrinterName) attr).getValue();
                if (sPrinterName.toLowerCase().indexOf("zebra") >= 0) {
                    psZebra = services[i];
                    break;
                }
            }
     
            if (psZebra == null) {
                System.out.println("Zebra printer is not found.");
                return;
            }
                String code="1323";
                BufferedImage img=new BufferedImage(100,100,BufferedImage.TYPE_INT_RGB);
                Graphics g=img.getGraphics();
                g.setColor(Color.BLACK);
                g.drawString(code,5,5);
                ByteArrayOutputStream outstream=new ByteArrayOutputStream();
                ImageIO.write( img, "jpg", outstream);
                byte[] buf=outstream.toByteArray();
                String value=new String(buf);
            System.out.println("Found printer: " + sPrinterName);
            DocPrintJob job = psZebra.createPrintJob();
            // Prepare string to send to the printer
            String s =  "R0,0\n" +   // Set Reference Point                                                             
                        "N\n" +         // Clear Image Buffer                                                             
                        "ZB\n" + // Print direction (from Bottom of buffer)
                        "GW160,50,100,100,"+value+"\r\n"+
                        "Q122,16\n" +  // Set label Length and gap
                        "A160,2,0,3,1,1,N,\"DATA: " + dateString + " - CARUGATE\"\n" +
                        "B160,30,0,1A,2,7,50,N,\"6120\"\n" +                            
                        "A160,92,0,1,1,1,N,\"AIA AGRICOLA IT.ALIMENT.S - 594679/VR                       \"\n" +
                        "P1\n";   // Print content of buffer, 1 label
            byte[] by = s.getBytes();
            DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
            // MIME type = "application/octet-stream",
            // print data representation class name = "[B" (byte array).
            Doc doc = new SimpleDoc(by, flavor, null);
            System.out.println("Pronti alla stampa");
            job.print(doc, null);
            System.out.println("Stampa inviata");
            } catch (Exception e) {
                e.printStackTrace();
        }


  2. #2
    Junior Member
    Join Date
    Feb 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: send image (logo) and text & barcode to the Zebra Printer

    Did you get any solution to this problem... i also need to send Fedex Shipping label directly to zebra printer that is on network..

  3. #3
    Junior Member
    Join Date
    Jun 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: send image (logo) and text & barcode to the Zebra Printer

    hi, did u get above problem solution. if u get that solution send me mail. my mail id . i am also suffering same problem.
    sureshreddyf@krishct.com

  4. #4
    Junior Member
    Join Date
    Jun 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: send image (logo) and text & barcode to the Zebra Printer

    mail id sureshreddy@krishct.com

Similar Threads

  1. Text to Tiff Image
    By sreddy_k in forum File I/O & Other I/O Streams
    Replies: 4
    Last Post: August 13th, 2009, 12:36 AM
  2. Problem on sending vectors from Java server to C# client
    By MS_Dark in forum Java Networking
    Replies: 2
    Last Post: July 7th, 2009, 02:35 PM
  3. How to format text in java?
    By fourseven in forum Java Theory & Questions
    Replies: 3
    Last Post: May 16th, 2009, 09:42 PM
  4. How to Send command line arguments in Eclipse?
    By JavaPF in forum Java JDK & IDE Tutorials
    Replies: 0
    Last Post: April 23rd, 2009, 11:37 AM
  5. UDP server sends thread application
    By Koren3 in forum Threads
    Replies: 2
    Last Post: April 20th, 2009, 11:46 AM