Printing in Android

Anonymous (not verified) -
3 MIN READ

Hi Everyone,

I thought, now that you know why printing is important and needs to be thought about earlier in the development process, you might want to know how to actually print with a Zebra device.  It’s a lot like making a connection to other devices.  The main difference is that most other devices, you are usually attempting to get information (like a picture, or a scan), and printers you are usually sending information. 

 

If you have any recommendations for content you want to see, please let me know.  For my example, I’m using a Motorola ET1, a Zebra QLn220 printer and the Zebra Link-OS Multiplatform SDK.  I’m going to create a connection, make sure the printer is ready, and then print something.  And now for some code…

 

import android.os.Looper;

import com.zebra.sdk.comm.BluetoothConnectionInsecure;

import com.zebra.sdk.comm.Connection;

 

public class BluetoothConnectionInsecureExample {

    public static void main(String[] args) {

        BluetoothConnectionInsecureExample example = new BluetoothConnectionInsecureExample();

 

        // The Bluetooth MAC address can be discovered, scanned, or typed in

        String theBtMacAddress = "00:11:BB:DD:55:FF";

        example.sendZplOverBluetooth(theBtMacAddress);

    }

 

    private void sendZplOverBluetooth(final String theBtMacAddress) {

        new Thread(new Runnable() {

            public void run() {

                try {

                    // Instantiate insecure connection for given Bluetooth MAC Address.

                    Connection thePrinterConn = new BluetoothConnectionInsecure(theBtMacAddress);

 

 

                    // Verify the printer is ready to print

                    if (isPrinterReady(thePrinterConn)) {

 

 

                    // Initialize

                    Looper.prepare();

 

                    // Open the connection - physical connection is established here.

                    thePrinterConn.open();

 

                    // This example prints "This is a ZPL test." near the top of the label.

                    String zplData = "^XA^FO20,20^A0N,25,25^FDThis is a ZPL test.^FS^XZ";

 

                    // Send the data to printer as a byte array.

                    thePrinterConn.write(zplData.getBytes());

 

                    // Make sure the data got to the printer before closing the connection

                    Thread.sleep(500);

 

                    // Close the insecure connection to release resources.

                    thePrinterConn.close();

 

                    Looper.myLooper().quit();

                }

            } catch (Exception e) {

                // Handle communications error here.

                e.printStackTrace();

            }

        }

    }).start();

 

 

    private bool isPrinterReady(Connection thePrinterConn) {

        bool isOK = false;

        try {

            connection.open();

            // Creates a ZebraPrinter object to use Zebra specific functionality like getCurrentStatus()

            ZebraPrinter printer = ZebraPrinterFactory.getInstance(connection);

 

            PrinterStatus printerStatus = printer.getCurrentStatus();

            if (printerStatus.isReadyToPrint) {

                isOK = true;

            } else if (printerStatus.isPaused) {

                System.out.println("Cannot Print because the printer is paused.");

            } else if (printerStatus.isHeadOpen) {

                System.out.println("Cannot Print because the printer media door is open.");

            } else if (printerStatus.isPaperOut) {

                System.out.println("Cannot Print because the paper is out.");

            } else {

                System.out.println("Cannot Print.");

            }

        } catch (ConnectionException e) {

            e.printStackTrace();

        } catch (ZebraPrinterLanguageUnknownException e) {

            e.printStackTrace();

        }

        return isOK;

    }

}

profile

Anonymous (not verified)

Dfghjkjjn

Please register or login to post a reply

28 Replies

R Ritesh Gupta

Very helpful blog.  Thanks for the code sample .

V Vedsatx Saddvv

At a high level, yes.&nbsp; Unfortunately our Android SDK doesn't have any helper functions for Serial.&nbsp; It means you need to open the Serial connection yourself.&nbsp; If you want to check the status of the printer before printing (which I highly recommend), you need to do that manually by sending the check status command and reading the response. The string "~HQES"&nbsp; will get you the information about the status.&nbsp; Just send it as a byte array and wait for the response (I would say 3 seconds max). The first byte of the response is a "0" for a printer ready, anything else is an error or warning condition. <a href="http://www.zebra.com/content/dam/zebra/manuals/en-us/software/zpl-zbi2-… the manual</a> for more info.&nbsp; The zplData string in the above example is accurate to print a test label.
Hope this helps.

I Ignacio Machin

Hi,

Is there any way to do it without the Thread.sleep at the end?
All the code I've seen so far relay on that. It is kind of imprecise , it can be 5 s some times but other could need more.

Thank,
Ignacio

I Ignacio Machin

Hi Robin,

One more question.

I'm trying to find the printer in the bonded devices. I'm iterating in the collection looking for the correct device type. These are the values I'm getting for my iMZ320 printer:
BluetoothClass.MajorDeviceClass = Imaging
BluetoothClass.DeviceClass = 1664

Can I assume that other mobile printers (RW420) will also present themselve like that?

Thank,
IGnacio

V Vedsatx Saddvv

Hi Ignacio, Yes, this is the device class for printers in general.&nbsp; Zebra printers will all present themselves that way.&nbsp;
On a related note, Zebra uses the SPP Bluetooth profile for communication.

V Vedsatx Saddvv

Hi Deepak,
Are you trying to connect over Bluetooth or Wi-Fi?&nbsp; I've never run across that specific error before.
One thing to try is to set up the printer connection first.&nbsp; If you are using Bluetooth, pair the printer to the Android device first. For either Bluetooth or Wi-Fi, open the Zebra Utilities app.&nbsp; Tap the Android menu button to get the Zebra Utilities menu.&nbsp; One option should be "Choose Printer".&nbsp; If you tap it, you should start to get a list of devices in your area, both Bluetooth and networked.&nbsp; You should see your printer listed.&nbsp; You can check by the serial number listed on the underside of the RW unless you changed the Bluetooth Friendly name of the printer. Tap the printer listed.&nbsp; Then you should be able to go in and print from one of the demos.

V Vedsatx Saddvv

Thanks Ignacio.
This could be very helpful to others using Xamarin.

a achbab mohamed

Hello, I'm programming a WinDev Mobile application (18) as part of my graduation project. My concern is that I must Print (Printer Zebra IMZ 220) Bluetooth from an Android application. Robin Do you have an experience about this ?
greeting

I Ignacio Machin

NP Robin,

I do have a somewhat similar code for the IOS, printing using only the IOS Bluetooth API.

I have one problem now.Not directly linked to Bluetooth printing.

I want to include an image of the signature captured, when I try to use the GFA it prints only the top portion of the image.

This happen also when communicating directly from the workstation to the printer using a USB cable.

So basically the question is , what else beside the GFA command I need to print an image using ZPL?

In anycase, here is my label

^XA^PON^MNN^LL855^FO15,90^ADN,36,20^FDInvoice^FS^FO250,90^ADN,18,10^FDDate: 06/09/14 1:29 AM^FS
^FO15,133^ADN,36,20^FDLaceup demo^FS^FO15,176^ADN,18,10^FD10450 falcon ave^FS^FO15,201^ADN,18,10^FDMiami fl 33166^FS^FO15,226^ADN,18,10^FDPhone: 305 3363636^FS^FO15,276^ADN,36,20^FDClient:^FS^FO15,319^ADN,36,20^FDExtra Supermarket^FS^FO15,362^ADN,18,10^FD12890 SW 8 st^FS^FO15,387^ADN,18,10^FDMiami FL, 33184 ^FS^FO15,455^A0N,36,20^FDInvoice Number:10608149^FS^FO15,498^ADN,18,10^FDSalesman:Laceup test salesman^FS^FO15,563^ADN,18,10^FDProduct^FS^FO300,563^ADN,18,10^FDQty^FS^FO360,563^ADN,18,10^FDPrice^FS^FO460,563^ADN,18,10^FDTotal^FS^FO15,588^ADN,18,10^FDCafe Bustelo^FS^FO300,588^ADN,18,10^FD1^FS^FS^FO360,588^ADN,18,10^FD$34.35^FS^FO460,588^ADN,18,10^FD$34.35^FS^FO15,641^ADN,18,10^FD-------------^FS^FO15,666^ADN,36,20^FD&nbsp;&nbsp;&nbsp; Total:$34.35^FS^FO15,709^ADN,36,20^FDQty Items:1^FS^FO15,752^ADN,36,20^FDQty Units:1^FS^FO15,795^GFA, 17920,17920,80,0000000001FFFF0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030001F000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000060000F8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C00000C0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000018000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E0000003000000000000000000000000000000000000000000000000000000000000FFFC000000000000000000000000000000000000000000000000000000000000000000000000000000000000000300000003000000000000000000000000000000000000000000000000000000000000FFFC000000000000000000000000000000000000000000000000000000000000000000000000000000000000000700000001000000000000000000000000000000000000000000000000000000000001000F00000000000000000000000000000000000000000000000000000000000000FFFFE00000000000000000000600000000C00000000000000000000000000000000000000000000000000000000003000F00000000000000000000000000000000000000000000000000000000000000FFFFF00000000000000000000600000000200000000000000000000000000001FFFE0000000000000000000000003F0000C00000000000000000000000003FFFFFFFFC000000000000000000000000070000180000000000000C00000600000000180000000000000000000000000001FFFE000000000000000000000000FF0000C0000000000000000000000000FFFFFFFFFE0000000000000000000000000F0000180000000000000C000006000000000C000000000000000000000000003F0003000000000000000000000000C00000F0000000000000000000000000C000000007F000000000000000000000000C00000C0000000000000C000006000000000600000000000000000000000000FE0003000000000000000000000007000000F0000000000000000000000000C000000003F800000000000000000000000C00000C0000000000000C00000C000000000300000000000000000000000000E0000100000000000000000000000E00000030000000000000000000000000C0000000000C00000000000000000000000C0000060000000000000C000018000000000300000000000000000000000000E0000100000000000000000000001800000038000000000000000000000000C0000000000600000000000000000000000C0000060000000000000C000030000000000300000000000000000000000000E00000C000000000000000000000180000001C000000000000000000000000C000000000030000000000000000000000180000030000000000000C0000E0000000000300000000000000000000000001E00000C000000000000000000000F80000000C000000000000000000000000C000000000010000000000000000000000F0000001C000000000000C0000E0000000000100000000000000000000000003000000C000000000000000000000F00000000E000000000000000000000000C00000000000C000000000000000000000E0000000E000000000000C0000E0000000000100000000000000000000000006000000C000000000000000000001000000000E000000000000000000000000C00000000000C000000000000000000000C0000000E000000000000C0000E0000000000100000000000000000000000006000000C0000000000000000000010000000006000000000000000000000000000000000000E000000000000000000000C0000000E000000000000C0000E00000000000C000000000000000000000000C000000E00000000000000000000100000000060000000000000000000000010000000000003000000000000000000000C0000000E000000000000C0000C00000000000C0000000000000000000000018000000F00000000000000000000100000000030000000000000000000000030000000000003000000000000000000000C0000000E000000000000C0000C00000000000C0000000000000000000000018000000300000000000000000000100000000010000000000000000000000030000000000003000000000000000000000C0000000E000000000000C0000C00000000000E000000000000000000000001800000018000000000000000000010000000000E000000000000000000000030000000000003000000000000000000001000000003000000000000C0000C00000000000E000000000000000000000003000000018000000000000000000010000000000F800000000000000000000030000000000003000000000000000000003000000001C00000000000C0000C00000000000E00000000000000000000000E0000000180000000000000000000700000000001E00000000000000000000060000000000003000000000000000000006000000000E00000000000C0000C00000000000300000000000000000000000C00000000C00000000000000000006000000000006000000000000000000000C0000000000003000000000000000000006000000000600000000000C0000C00000000000300000000000000000000001000000000C000000000000000000060000000000060000000000000000000018000000000000300000000000000000000C000000000600000000000C0000C00000000000180000000000000000000003000000000C000000000000000000060000000000070000000000000000000018000000000000300000000000000000000C000000000600000000000C0000C0000000000018000000000000000000000E0000000006000000000000000000060000000000010000000000000000000030000000000000300000000000000000000C000000000600000000000C0000C0000000000018000000000000000000001C000000000300000000000000000006000000000000E000000000000000000030000000000000300000000000000000001C000000000600000000000C0000C000000000000C0000000000000000000030000000000300000000000000000006000000000000F0000000000000000000300000000000003000000000000000000038000000000300000000000C0000C000000000000C00000000000000000000E000000000030000000000000000000600000000000018000000000000000000300000000000003000000000000000000030000000000300000000000C0000C000000000000C00000000000000000000E000000000030000000000000000000600000000000018000000000000000000300000000000003000000000000000000030000000000300000000000C0000C000000000000600000000000000000000C000000000030000000000000000000600000000000018000000000000000000F00000000000003000000000000000000030000000000100000000000C0000C000000000000600000000000000000000C000000000030000000000000000000600000000000018000000000000000000F00000000000003000000000000000000020000000000100000000000C0000C000000000000600000000000000000000C000000000030000000000000000000C0000000000001E0000000000000000012000000000000030000000000000000000E00000000000C0000000000C0000C000000000000300000000000000000000C000000000030000000000000000000C0000000000001F0000000000000000030000000000000030000000000000000000E00000000000C0000000000C0000C00000000000030000000000000000000100000000000300000000000000000018000000000000010000000000000000060000000000000030000000000000000001C00000000000C0000000000C0000C00000000000030000000000000000000300000000000300000000000000000030000000000000010000000000000000060000000000000030000000000000000003C00000000000E0000000000C0000C000000000000300000000000000000007000000000003000000000000000000E00000000000000100000000000000000C0000000000000030000000000000000003000000000000F000000000180000C00000000000010000000000000000000F000000000003000000000000000000E00000000000000100000000000000000C00000000000000300000000000000000030000000000003000000000180000C00000000000010000000000000000000C000000000003000000000000000000E00000000000000100000000000000000C00000000000000300000000000000000030000000000003000000000180000C00000000000010000000000000000000C000000000003000000000000000000C00000000000000100000000000000000C00000000000000300000000000000000030000000000003000000000180000C00000000000010000000000000000000C000000000003000000000000000000C00000000000000100000000000000000C00000000000000300000000000000000030000000000003000000000180000C00000000000010000000000000000000C000000000003000000000000000000C00000000000000100000000000000000C00000000000000300000000000000000070000000000003000000000180000C00000000000010000000000000000000C000000000003000000000000000001000000000000000100000000000000000C000000000000003000000000000000000E0000000000003000000000180000C00000000000010000000000000000000C000000000003000000000000000001000000000000000100000000000000000C00000000000000300000000000000000180000000000003000000000180000C0000000000001000000000000000000F8000000000003000000000000000001000000000000000100000000000000000C00000000000000300000000000000000180000000000003000000000100000C0000000000001000000000000000000F0000000000003000000000000000001000000000000000100000000000000000C00000000000000300000000000000000180000000000003000000000300000C0000000000001000000000000000000C0000000000003000000000000000001000000000000000100000000000000000C00000000000000300000000000000000180000000000003000000000300000C0000000000001000000000000000000C0000000000003000000000000000001000000000000000100000000000000000C00000000000000300000000000000000180000000000003800000000300000C0000000000001000000000000000000C0000000000003000000000000000001000000000000000100000000000000000C00000000000000300000000000000000180000000000001C00000000300000C0000000000001000000000000000000C0000000000001000000000000000001000000000000000100000000000000000C00000000000000300000000000000000180000000000000C00000000300000C000000000000100000000000000000100000000000001000000000000000003000000000000000100000000000000000C00000000000000300000000000000000300000000000000C00000000300000C000000000000100000000000000000300000000000001000000000000000003000000000000000100000000000000000C00000000000000300000000000000000300000000000000C00000000300000C000000000000100000000000000000300000000000000C00000000000000003000000000000000100000000000000001C00000000000000300000000000000000E00000000000000C00000000300000C000000000000100000000000000000300000000000000C00000000000000006000000000000000100000000000000003800000000000000300000000000000000E00000000000000C00000000300000C000000000000100000000000000000300000000000000C00000000000000006000000000000000100000000000000003000000000000000300000000000000000E00000000000000C00000000300000C000000000000100000000000000000300000000000000C00000000000000006000000000000000100000000000000003000000000000000300000000000000000E00000000000000600000000300000C000000000000100000000000000000300000000000000C000000000000000060000000000000000C0000000000000003000000000000000300000000000000000E00000000000000600000000300000C000000000000100000000000000000600000000000000C000000000000000040000000000000000C0000000000000003000000000000000300000000000000000C00000000000000300000000300000C000000000000100000000000000000600000000000000C0000000000000000C0000000000000000E0000000000000003000000000000000300000000000000001000000000000000300000000300000C000000000000100000000000000000600000000000000C000000000000000180000000000000000E0000000000000003000000000000000300000000000000003000000000000000100000000300000C000000000000100000000000000000600000000000000C000000000000000180000000000000000E0000000000000003000000000000000300000000000000006000000000000000100000000300000C000000000000100000000000000000600000000000000C000000000000000180000000000000000300000000000000030000000000000003000000000000000060000000000000000C0000000300000C000000000000100000000000000000600000000000000C0000000000000001800000000000000003000000000000000E0000000000000003000000000000000060000000000000000C0000000300000C000000000000100000000000000000600000000000000C0000000000000001800000000000000003000000000000000C0000000000000003000000000000000060000000000000000E0000000300000C000000000000100000000000000000600000000000000C0000000000000001800000000000000001800000000000000C0000000000000003000000000000000060000000000000000E0000000300000C000000000000100000000000000000600000000000000C0000000000000003000000000000000001800000000000000C0000000000000003000000000000000060000000000000000E0000000300000C000000000000100000000000000000600000000000000C0000000000000003000000000000000001800000000000000C000000000000000300000000000000006000000000000000030000000300000C000000000000100000000000000000C00000000000000C0000000000000003000000000000000001800000000000000C000000000000000300000000000000006000000000000000030000000300000C000000000000100000000000000001800000000000000C0000000000000003000000000000000001800000000000000C000000000000000300000000000000006000000000000000030000000300000C000000000000100000000000000001800000000000000C0000000000000003000000000000000001800000000000000C000000000000000300000000000000006000000000000000030000000300000C000000000000100000000000000001800000000000000C0000000000000003000000000000000001800000000000000C000000000000000300000000000000006000000000000000030000000300000C000000000000100000000000000001800000000000000C0000000000000003000000000000000001800000000000000C000000000000000300000000000000006000000000000000030000000300000C000000000000100000000000000001800000000000000C0000000000000003000000000000000001800000000000000C000000000000000300000000000000006000000000000000030000000300000E000000000000100000000000000001800000000000000E0000000000000003000000000000000001800000000000000C0000000000000003000000000000000060000000000000000300000003000003000000000000100000000000000001800000000000000E000000000000000300000000000000000180000000000000100000000000000003000000000000000060000000000000000300000003000003000000000000100000000000000001800000000000000300000000000000030000000000000000018000000000000010000000000000000300000000000000006000000000000000018000000300000180000000000010000000000000000300000000000000030000000000000003000000000000000001E000000000000030000000000000000E000000000000000060000000000000000180000003000001800000000000100000000000000003000000000000000300000000000000030000000000000000006000000000000030000000000000000E00000000000000006000000000000000018000000300000180000000000010000000000000000E000000000000000300000000000000030000000000000000006000000000000030000000000000000C0000000000000000600000000000000000C000000300000180000000000010000000000000000E0000000000000003000000000000000E0000000000000000006000000000000030000000000000000C0000000000000000600000000000000000C000000300000180000000000010000000000000000E0000000000000003000000000000000C000000000000000000600000000000003000000000000000100000000000000000600000000000000000C000000300000180000000000010000000000000000E0000000000000003000000000000000C000000000000000000600000000000003000000000000000100000000000000000600000000000000000C000000300000180000000000010000000000000000E00000000000000030000000000000010000000000000000000600000000000003000000000000000300000000000000000600000000000000000C000000300000180000000000010000000000000000E00000000000000030000000000000010000000000000000000600000000000003000000000000000300000000000000000600000000000000000C000000300000180000000000010000000000000000E0000000000000003000000000000003000000000000000000060000000000000E000000000000000300000000000000000600000000000000000C000000300000180000000000010000000000000000E0000000000000003000000000000003000000000000000000060000000000000C000000000000000600000000000000000600000000000000000C000000300000180000000000010000000000000000E0000000000000003000000000000003000000000000000000060000000000000C00000000000000060000000000000000060000000000000000070000003000001C0000000000010000000000000000E0000000000000003000000000000003000000000000000000060000000000000C00000000000000060000000000000000060000000000000000030000003000000E0000000000010000000000000000E0000000000000003000000000000003000000000000000000060000000000000C000000000000000C000000000000000006000000000000000000C00000300000060000000000010000000000000000E0000000000000003000000000000003000000000000000000060000000000000C000000000000000C000000000000000006000000000000000000C00000300000060000000000010000000000000000E0000000000000003000000000000003000000000000000000060000000000000C000000000000000C000000000000000006000000000000000000C00000300000060000000000010000000000000000E0000000000000003000000000000003000000000000000000060000000000000C000000000000000C000000000000000006000000000000000000C00000300000060000000000010000000000000000E00000000000000030000000000000030000000000000000000600000000000038000000000000000C000000000000000006000000000000000000C00000300000060000000000010000000000000000E000000000000000300000000000000300000000000000000006000000000000300000000000000018000000000000000006000000000000000000C00000300000060000000000010000000000000000E000000000000000300000000000000600000000000000000006000000000000300000000000000018000000000000000006000000000000000000C00000300000060000000000010000000000000000E000000000000000300000000000000600000000000000000006000000000000300000000000000018000000000000000006000000000000000000E00000300000060000000000010000000000000000E000000000000000300000000000000600000000000000000006000000000000300000000000000030000000000000000006000000000000000000E00000300000060000000000010000000000000000E000000000000000300000000000000400000000000000000006000000000000300000000000000030000000000000000006000000000000000000E00000300000060000000000010000000000000000C000000000000000300000000000000C00000000000000000006000000000000300000000000000030000000000000000006000000000000000000300000300000070000000000010000000000000000C000000000000000180000000000000C00000000000000000006000000000000E00000000000000030000000000000000006000000000000000000300000300000030000000000010000000000000000C000000000000000180000000000000C00000000000000000006000000000000C00000000000000030000000000000000006000000000000000000180000300000010000000000010000000000000000C000000000000000180000000000000C00000000000000000006000000000000C000000000000000E00000000000000000060000000000000000000C000030000000C0000000000100000000000000010000000000000000180000000000000C00000000000000000006000000000000C000000000000000E00000000000000000060000000000000000000C000030000000C00000000001000000000000000100000000000000000C0000000000000C00000000000000000006000000000000C000000000000000C000000000000000000600000000000000000006000030000000E00000000001000000000000000100000000000000000C0000000000000C000000000000000000060000000000010000000000000000C000000000000000000600000000000000000006000030000000E00000000001000000000000000100000000000000000C0000000000000C000000000000000000060000000000010000000000000000C000000000000000000600000000000000000006000030000000E00000000001000000000000000100000000000000000C00000000000018000000000000000000060000000000010000000000000000C000000000000000000600000000000000000003000030000000300000000001000000000000000100000000000000000C000000000000180000000000000000000600000000000100000000000000010000000000000000000600000000000000000003000030000000300000000001000000000000000100000000000000000C000000000000180000000000000000000600000000000100000000000000010000000000000000000600000000000000000003000030000000300000000001000000000000000100000000000000000C000000000000300000000000000000000600000000000100000000000000010000000000000000000600000000000000000001000030000000180000000001000000000000000100000000000000000C000000000000300000000000000000000600000000000100000000000000010000000000000000000600000000000000000000000030000000180000000001000000000000000100000000000000000C000000000000300000000000000000000600000000000100000000000000030000000000000000000600000000000000000000C00030000000180000000001000000000000000100000000000000000C000000000000300000000000000000000600000000000100000000000000030000000000000000000600000000000000000000C000300000000C00000000010000000000000001000000000000000006000000000000300000000000000000000600000000000100000000000000030000000000000000000600000000000000000000C000300000000C00000000010000000000000001000000000000000006000000000000300000000000000000000600000000000100000000000000060000000000000000000600000000000000000000C000300000000C00000000010000000000000001000000000000000006000000000000300000000000000000000600000000000100000000000000060000000000000000000600000000000000000000C000300000000600000000010000000000000001000000000000000003000000000000300000000000000000000600000000000100000000000000060000000000000000000600000000000000000000C0003000000006000000000100000000000000010000000000000000030000000000003000000000000000000003000000000003000000000000000C0000000000000000000600000000000000000000C0003000000006000000000100000000000000010000000000000000030000000000003000000000000000000003000000000003000000000000000C0000000000000000000600000000000000000000C000300000000200000000010000000000000001000000000000000003000000000000300000000000000000000300000000000600000000000000180000000000000000000600000000000000000000C000300000000300000000010000000000000001000000000000000003000000000000300000000000000000000300000000000600000000000000180000000000000000000600000000000000000000C000300000000300000000010000000000000001000000000000000003000000000000300000000000000000000300000000000C00000000000000300000000000000000000600000000000000000000E000300000000300000000010000000000000001000000000000000003000000000000300000000000000000000300000000001800000000000000300000000000000000000C00000000000000000000E0003000000003000000000100000000000000010000000000000000030000000000003000000000000000000003000000000018000000000000003000000000000000000018000000000000000000003000300000000100000000010000000000000001000000000000000003000000000000300000000000000000000300000000003000000000000000300000000000000000001800000000000000000000300030000000010000000001000000000000000100000000000000000300000000000030000000000000000000030000000000E000000000000000300000000000000000001800000000000000000000180030000000010000000001000000000000000100000000000000000300000000000030000000000000000000030000000000E0000000000000003000000000000000000018000000000000000000000C003000000000C000000001000000000000000100000000000000000300000000000030000000000000000000030000000000E0000000000000003000000000000000000018000000000000000000000C003000000000E0000000010000000000000001000000000000000003000000000000E000000000000000000001C000000000E00000000000000030000000000000000000180000000000000000000006003000000000E0000000010000000000000001000000000000000003000000000000E000000000000000000000C000000000E00000000000000030000000000000000000180000000000000000000006003000000000E0000000010000000000000001000000000000000003000000000000C000000000000000000000C000000000E00000000000000030000000000000000000300000000000000000000003003000000000E00000000100000000000000030000000000000000030000000000010000000000000000000000C000000000E00000000000000030000000000000000000300000000000000000000003003000000000E00000000100000000000000030000000000000000030000000000030000000000000000000000C000000000E00000000000000030000000000000000000E00000000000000000000001003000000000E00000000100000000000000030000000000000000030000000000030000000000000000000000C000000000E00000000000000030000000000000000000C00000000000000000000001003000000000E00000000100000000000000060000000000000000030000000000030000000000000000000000C000000000E00000000000000030000000000000000001000000000000000000000000C03000000000E00000000100000000000000060000000000000000030000000000030000000000000000000000C000000000E00000000000000030000000000000000001000000000000000000000000C03000000000E00000000100000000000000060000000000000000030000000000030000000000000000000000E000000000C00000000000000030000000000000000001000000000000000000000000E03000000000E00000000100000000000000060000000000000000030000000000030000000000000000000000E000000000C00000000000000030000000000000000003000000000000000000000000E03000000000E00000000100000000000000060000000000000000030000000000030000000000000000000000300000000100000000000000003000000000000000000300000000000000000000000030300000000030000000010000000000000006000000000000000003000000000003000000000000000000000030000000010000000000000000300000000000000000030000000000000000000000003030000000003000000001000000000000000600000000000000000300000000000300000000000000000000003000000001000000000000000030000000000000000003000000000000000000000000183000000000180000000100000000000000060000000000000000030000000000030000000000000000000000300000000300000000000000003000000000000000000600000000000000000000000018300000000018000000010000000000000006000000000000000003000000000003000000000000000000000030000000030000000000000000300000000000000000060000000000000000000000001830000000001800000001000000000000000C000000000000000003000000000003000000000000000000000030000000060000000000000000300000000000000000060000000000000000000000001830000000000C00000001000000000000000C0000000000000000030000000000060000000000000000000000300000000C0000000000000000300000000000000000060000000000000000000000000C30000000000C00000001000000000000000C0000000000000000030000000000060000000000000000000000300000000C0000000000000000300000000000000000060000000000000000000000000C30000000000C00000001000000000000001800000000000000000300000000000C000000000000000000000030000000180000000000000000300000000000000000060000000000000000000000000C30000000000600000001000000000000001800000000000000000300000000001800000000000000000000003000000018000000000000000030000000000000000006000000000000000000000000063000000000060000000100000000000000300000000000000000010000000000180000000000000000000000300000001800000000000000003000000000000000000C00000000000000000000000006300000000006000000010000000000000030000000000000000000C000000000300000000000000000000000300000003000000000000000003000000000000000000800000000000000000000000006E0000000000300000000F0000000000000E0000000000000000000F000000000E00000000000000000000000300000003000000000000000001800000000000000001800000000000000000000000006E0000000000100000000F8000000000000E00000000000000000003C00000000C0000000000000000000000030000000E000000000000000000C00000000000000003000000000000000000000000006C000000000010000000018000000000000C00000000000000000000E00000000C0000000000000000000000030000000E000000000000000000C0000000000000000E000000000000000000000000006C00000000000000000000C000000000000C00000000000000000000300000000C0000000000000000000000030000000C00000000000000000060000000000000000C000000000000000000000000006C00000000000C00000000C000000000001000000000000000000000300000001000000000000000000000000300000010000000000000000000600000000000000030000000000000000000000000006C00000000000C00000000C0000000000030000000000000000000000C0000001000000000000000000000000300000070000000000000000000600000000000000070000000000000000000000000006C00000000000C0000000060000000000060000000000000000000000C00000010000000000000000000000003000000E00000000000000000006000000000000000C0000000000000000000000000006C00000000000C00000000600000000000E0000000000000000000000FE0000030000000000000000000000001800000C0000000000000000000300000000000000180000000000000000000000000006C00000000000E00000000600000000001E0000000000000000000000FF000003000000000000000000000000180000180000000000000000000300000000000000300000000000000000000000000006C00000000000E00000000300000000003000000000000000000000000300000E0000000000000000000000000C0000180000000000000000000300000000000000E00000000000000000000000000006C00000000000E000000001000000000030000000000000000000000001E0003C0000000000000000000000000C0000180000000000000000000300000000000000E00000000000000000000000000006C00000000000E000000000C000000000E0000000000000000000000000FFFFF00000000000000000000000000C0000180000000000000000000300000000000000E00000000000000000000000000006C00000000000E0000000002000000000C00000000000000000000000001FFFC00000000000000000000000000C0000180000000000000000000300000000000001C00000000000000000000000000006C00000000000E0000000001000000006C00000000000000000000000000000000000000000000000000000000C0000300000000000000000000300000000000007000000000000000000000000000006C00000000000E000000000080000000F000000000000000000000000000000000000000000000000000000000C0000E0000000000000000000030000000000000C000000000000000000000000000006C00000000000E0000000000400000019000000000000000000000000000000000000000000000000000000000C0000E00000000000000000000300000000000018000000000000000000000000000006C00000000000E00000000002000000F0000000000000000000000000000000000000000000000000000000000C0000E00000000000000000000300000000000030000000000000000000000000000006C00000000000E00000000001000001E0000000000000000000000000000000000000000000000000000000000C0000C000000000000000000001C00000000000F0000000000000000000000000000000C00000000000E0000000000100000300000000000000000000000000000000000000000000000000000000000C00010000000000000000000000C00000000001F0000000000000000000000000000000C00000000000E00000000000FFFFFE00000000000000000000000000000000000000000000000000000000000C00010000000000000000000000E0000000000300000000000000000000000000000000C00000000000E00000000000FFFFFC00000000000000000000000000000000000000000000000000000000000C00030000000000000000000000E0000000000E00000000000000000000000000000000C00000000000E00000000000000000000000000000000000000000000000000000000000000000000000000007FFFE0000000000000000000000E0000000003C00000000000000000000000000000000C00000000000E00000000000000000000000000000000000000000000000000000000000000000000000000003FFFC00000000000000000000002000000003F000000000000000000000000000000000C00000000000E00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003C000000FFC000000000000000000000000000000000C00000000001E00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003F00003FFC0000000000000000000000000000000000C00000000003C000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000013FFFFFF000000000000000000000000000000000000C000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FFFF00000000000000000000000000000000000000C000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C000000000060000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C0000000000C0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C000000000180000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C000000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C000000000E00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C000000000C00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C000000003000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C00000000C000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C000000038000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C0000000F0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C0000001C0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C000000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C000000E00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C00000FC00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C00000F000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FFFFFF0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FFFFFF000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000^XZ

V Vedsatx Saddvv

Hi Ignacio,
This is an easy fix.&nbsp; Your label length is too short.&nbsp; Change the ^LL at the top of the format from ^LL855 to something like ^LL1100.

I Ignacio Machin

Thanks a lot !!!

a achbab mohamed

During the trial period we opted for (Zebra RW 220) I'll try to integrate Java code in Windev. If I have something special I'll contact. can i found documentation in French Robin?

V Vedsatx Saddvv

Many of our manuals and documentation are in multiple languages, including French. The SDK documentation is only in English though.

Robin West
Integration Architect
ZEBRA TECHNOLOGIES CORPORATION

333 Corporate Woods Parkway
Vernon Hills, IL 60061-3109
T: +1 847 793 2641
<a href="mailto:rwest@zebra.com">rwest@zebra.com</a&gt;
<a href="http://www.zebra.com/isv&lt;">www.zebra.com/isv&lt;</a><a>"&gt;http://w…;

J Jasson Trujillo Ortiz

Help me in android with print mz220 and rw420 report is error:
Could not connect to device: read failed, socket might closed or timeout, read ret: -1
at com.zebra.sdk.comm.ConnectionA.open(Unknown Source)
at com.zebra.sdk.comm.BluetoothConnection.open(Unknown Source)

Sorry english, hablo español

I ISV NALA

Hola Jasson,

Yo trabajo con el equipo ISV. Te puedo ayudar en tu requerimiento, pero voy a necesitar mas informacion para poder depurar el problema de comunicacion que se te esta presentando.

Por favor puedes explicarme con un poco mas de detalle la arquitectura de la solucion que estas implementando.

Si quieres puedes responderme al siguiente email : <a href="mailto:ISV_LATAM_Support@zebra.com">ISV_LATAM_Support@zebra.com</a&gt;

Manuel Caicedo

D Daniel Quagliana

Nayan, the <a href="/community/developer-events/blog/2016/11/11/dev-talks-december-14th-label-design-creating-unique-clear-labels-for-your-app">presentation from our Dev Talk on creating labels </a>has some great information that explains how to incorporate barcodes as well as make templates for labels.
<a href="/thread/33380">Additionally in this thread </a>Manuel explains the steps to add printing into your app.

N Nayan Kagade

Hi Guys, I want to make label including barcode how I can print label with barcode.

N Nayan Kagade

Hi Guys,

I want to print same label multiple times I am using code as per follows but not working label printing only single time:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

^XA,^LH20,30^FS,^FO5,0^A0,35,35^FDitemLookupCode^FS,^FO5,30^A0N,36,32^FDdescription^FS,^FO5,60^BY4^BC,80,N^FD&gt;;&gt;itemLookupCode^FS,^FO390,75^A0N,87,62^FD^FS,^FO5,150^A0N,36,32^FDsubDescription^FS,^PQ2,^XZ

Also I tried to use at the end of the code for multiple quantities but not worked^PQ2,0,1,Y,^XZ
^PQ2,0,1,N,^XZ&nbsp;&nbsp;&nbsp;&nbsp;

D Daniel Quagliana

To include a barcode on your label you will need to include ZPL code for the specific type of barcode and the data to be encoded. The <a href="https://www.zebra.com/content/dam/zebra/manuals/en-us/software/zpl-zbi2… Programming Guide</a> outlines the types of supported barcodes (^B commands as outlined in the index on page 3) and the parameters required to use them.

N Nayan Kagade

how I can make template for label?

D Darryn Campbell

Hey, can we print base64 image directly, or we need to convert in any other format?

S Sean Kennedy

I would assume Robin that this also goes the same for Tethered Serial Mode connected Printers as well? But instead of connecting Via Bluetooth, You would initialise the Serial Stream stack instead?

-sean

D Darryn Campbell

Hello Robin, I'll be back with other questions. can i send a file in XML or TXT format ( Zebra printer iMZ 220), because the data I want to send are from a database. Thank you for your Brightening !

I Ignacio Machin

Hi Robin,

Thanks for your fast answer.

I will give it a try.

BTW, you do not need to use the Zebra SDK at all to print, I'm printing from a C# (using Xamarin) using just the Bluetooth API provided by Android.

Thank,

Ignacio

I Ignacio Machin

Hello,

Here is printing using&nbsp; just the platform Bluetooth API.

The code is in C# (using Xamarin)
hope this help

using Android.Bluetooth;
using Java.IO;
using Java.Util;

string bt_printer = "00:22:58:02:35:52";
var x = BluetoothAdapter.DefaultAdapter.BondedDevices;

BluetoothSocket socket = null;
BufferedReader inReader = null;
BufferedWriter outReader = null;

BluetoothDevice hxm = BluetoothAdapter.DefaultAdapter.GetRemoteDevice (bt_printer);
UUID applicationUUID = UUID.FromString("00001101-0000-1000-8000-00805F9B34FB");

socket = hxm.CreateRfcommSocketToServiceRecord(applicationUUID);
socket.Connect();
inReader = new BufferedReader(new InputStreamReader(socket.InputStream));
outReader = new BufferedWriter(new OutputStreamWriter(socket.OutputStream));
outReader.Write(printingString);

outReader.Flush();
Thread.Sleep(5 * 1000);
var s = inReader.Ready();
inReader.Skip(0);
//close all
inReader.Close();
socket.Close();
outReader.Close();

D Deepak Donde

Hi Robin,

I am developing an android app in which i am trying to print using zebra <strong>RW220</strong> and <strong>RW420</strong>.
So I download the 'Zebra utilities' app from android playstore but whenever i tried to print something it <strong>always </strong>give one of following error-
1)error writing to connection:[JSR82]write:write failed
2)could not connect to device:[JSR82]
connect:connection is not created(failed or aborted)

How can I fix this?
I am trying to solve this from last two days,please help!!!

R Rajkumar Achuri

Hi Robin,
thanks for your blog , really helpful.

am developing Android App ,am new to Android Development and Bluetooth Interaction ,am using&nbsp; IMZ 320 printer and MOTOROLA- ET1 device,am unable to print the Arabic words ,the printer already installed with the Arabic fonts.can you please suggest me how to Print the Arabic Text followed By English.its really very helpful if you provide peace of code.

Thanks &amp; Regards,
Rajendra A.

V Vedsatx Saddvv

Hi Rajkumar, I'm traveling right now so getting you some code will take a few days.&nbsp; I can recommend a few things to try.&nbsp; In your print format, add the ^CI28 command near the beginning, so it looks like ^XA^CI28....&nbsp; Then you have a few options on how to tell the printer to use your font. You can either use font aliasing or just the ^A@ command to call your font by name.&nbsp;

More information than you want to know about fonts is <a href="https://km.zebra.com/resources/sites/ZEBRA/content/live/SOLUTIONS/8000/…;.