首页 文章

Zebra iMZ320无法理解命令[关闭]

提问于
浏览
5

我正在尝试将标签从Android应用程序打印到Zebra打印机(iMZ 320),但似乎不了解我的命令行 .

当我尝试这个示例代码时,打印机会在将它们发送到打印机时将所有命令打印到纸张上:

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

我已经阅读了Zebra官方网站上的ZPL编程教程,但我无法弄清楚如何使用ZPL命令使我的打印机正常工作 .

2 回答

  • 6

    Zebra iMZ可以在线打印模式下发货 . 这意味着它不会解析和解释您提供的ZPL命令,而是会打印它们 . 您需要将打印机配置为ZPL模式而不是行打印模式 . 以下命令应该这样做:

    ! U1 setvar“device.languages”“zpl”

    Note: 在某些情况下,您可能必须将语言设置为"hybrid_xml_zpl"而不仅仅是"zpl"

    请注意,您需要在此命令的末尾包含换行符(或回车符) . 您可以使用Zebra Setup Utilities通过“通信”视角直接向打印机发送命令,可通过点击主屏幕上的“通信”按钮获得 .

    Zebra设置实用程序:http://www.zebra.com/us/en/products-services/software/manage-software/zebra-setup-utility.html

    ZPL手册第705页(详细说明如上所列的命令):https://support.zebra.com/cpws/docs/zpl/zpl_manual.pdf

  • 1

    如果你想打印简单的文字你可以通过BT插座发送普通的“原始”数据到Zebra打印机,它将打印出来!您不需要使用Zebra打印库 .

    只需在异步任务中运行此代码即可打印两行纯文本:

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

相关问题