Command not being understood by Zebra iMZ320 [closed]

倾然丶 夕夏残阳落幕 提交于 2019-12-10 13:45:25

问题


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.


回答1:


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




回答2:


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;
}


来源:https://stackoverflow.com/questions/16088103/command-not-being-understood-by-zebra-imz320

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!