Command not being understood by Zebra iMZ320 [closed]
Asked Answered
I

2

6

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.

Indescribable answered 18/4, 2013 at 16:16 Comment(4)
Please reopen.I don't think this question should have been closed. I'm working with the Zebra iMZ320 on iOS right now. I'm figuring this out, too, when I do I'll post an answer in the comment if this is not reopened.Khoury
K, added my answer as a comment on jason's answer below.Khoury
Thank's jaime. I don't know who closed my post, i also think it should't be closed.Indescribable
I've nominated it for reopening, but it will require some additional votes from highly ranked users to go throughKingdon
K
6

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

Kafiristan answered 20/4, 2013 at 14:11 Comment(9)
Alternatively, you can send the command I listed above through your app instead of through Zebra Setup Utilities. You would, however, have to append a '\r\n' at the end of your string.Kafiristan
Finally the Zebra's "customer service" contacted me and they explained me that you have to send text commands in CPCL and images in ZPL, but their information is so complicated and useless that i can't still print anything with a good format. Thank you any way :)Indescribable
FOUND IT! You need to setvar to "hybrid_xml_zpl" because it ships in line print mode and setting to "zpl" does not work. km.zebra.com/kb/…Khoury
If anybody finds out if there's a drawback to this please comment... I have no idea why they ship in line print mode when this mode also handles CPCL.Khoury
I'm marking this question as good, althougth i could not print propperly, it was the most accurate solution, like jaime's solution setting setvar to hybrid_xml_zpl. Thank you all for your time :)Indescribable
I have modified the answer to include hybrid xml/zpl!Kafiristan
Does case matter? The references I've seen use "ZPL" not "zpl" (such as km.zebra.com/kb/index?page=content&id=SO7296)Heartbreak
@jason.zissman: Or just mash the "Enter" key at the end of the command (you don't need to explicitly add "\r\n")Heartbreak
The Zebra document that explains on how to set ZPL shows to use ZPL but this did not work for me. I had to use zpl like in the answer.Opheliaophelie
C
1

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;
}
Commentator answered 18/4, 2013 at 16:43 Comment(2)
I need to format text and print images, the printer is not understanding my commands with your code neither :(Indescribable
It prints the raw text if set to "line_print" mode; that's not what most people want, though. Zebra's default settings seem either thoughtless or nonsensical. With the QLn220, I have to send a command so that it does not shut off any time a command is sent to it! Bizarro!Heartbreak

© 2022 - 2024 — McMap. All rights reserved.