Question

I'm trying to print a label from an Android app to a Zebra printer (iMZ 320) but it seems not to be understanding my command line.

When I try this sample code, the printer prints all the commands to the paper as I send them to the printer:

zebraPrinterConnection.write("^XA^FO50,50^ADN,36,20^FDHELLO^FS^XZ".getBytes());

I've read the ZPL programming tutorial from Zebra's official website, but I can't figure out how to make my printer work all right with ZPL commands.

Was it helpful?

Solution

The Zebra iMZ may ship in line print mode. This means that it will not parse and interpret the ZPL commands that you have provided, but rather, it will print them. You'll need to configure the printer to ZPL mode instead of line print mode. The following command should do it:

! U1 setvar "device.languages" "zpl"

Note: In some cases you may have to set the language to "hybrid_xml_zpl" instead of just "zpl"

Notice that you need to include a newline character (or carriage return) at the end of this command. You can use Zebra Setup Utilities to send commands directly to the printer through its 'communication' perspective, available by hitting the 'communication' button on the main screen.

Zebra Setup Utilities: http://www.zebra.com/us/en/products-services/software/manage-software/zebra-setup-utility.html

ZPL Manual page 705 (details command such as the one listed above): https://support.zebra.com/cpws/docs/zpl/zpl_manual.pdf

OTHER TIPS

If you want to print simple text you can send normal "raw" data trough BT socket to Zebra printer and it will print it! You don't need to use Zebra print library.

Just run this code in async task to print two lines of plain text:

protected Object doInBackground(Object... params) {
    //bt address
    String bt_printer = "00:22:58:31:85:68";
    String print_this = "Hello Zebra!\rThis is second line";
    //vars
    BluetoothSocket socket = null;
    BufferedReader in = null;
    BufferedWriter out = null;
    //device from address
    BluetoothDevice hxm = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(bt_printer);
    UUID applicationUUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
    try {
        //create & connect to BT socket
        socket = hxm.createRfcommSocketToServiceRecord(applicationUUID);
        socket.connect();
        in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        out = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
        out.write(print_this);
        out.flush();
        //some waiting
        Thread.sleep(3000);
        //in - nothing, just wait to close connection
        in.ready();
        in.skip(0);
        //close all
        in.close();
        socket.close();
        out.close();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }       
    return null;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top