简体   繁体   English

从Android使用Zebra MZ220打印

[英]Printing with zebra MZ220 from android

What i´m trying to do is to print a label with zebra mz220 using the information I have in my SQLite database, but I don´t know how to fill in the label using strings. 我正在尝试使用zebra mz220使用我在SQLite数据库中拥有的信息来打印标签,但是我不知道如何使用字符串来填写标签。 Here is my code so far 到目前为止,这是我的代码


case R.id.bprint: 案例R.id.bprint:

        new Thread(new Runnable() {
            public void run() {
                try {

                    // Instantiate connection for given Bluetooth® MAC Address.
                    ZebraPrinterConnection thePrinterConn = new BluetoothPrinterConnection("00:22:58:3C:9F:0B");

                    // Initialize 
                    Looper.prepare();

                    // Open the connection - physical connection is established here.
                    thePrinterConn.open();



                    // here it should fill in the label but it doesn't =(
                    thePrinterConn.write("Input (ENCODING.LBL):! 0 200 200 200 1 ENCODING UTF-8 TEXT 0 20 30 r/n/ PRINTr/n/".getBytes());



                    //Make sure the data got to the printer before closing the connection
                    Thread.sleep(500);

                    // Close the connection to release resources.
                    thePrinterConn.close();

                    Looper.myLooper().quit();

                } catch (Exception e) {
                    // Handle communications error here
                    e.printStackTrace();
                }
            }
            }).start();

            break;

    case R.id.spb:

        startActivity(new Intent(this, Barcode.class));

        break;

please help, thanks 请帮助,谢谢

The code looks appropriate, but unfortunately your comment "I don't know how to fill in the label using strings" isn't very clear. 该代码看起来合适,但不幸的是,您的注释“我不知道如何使用字符串填写标签”不是很清楚。 What is the outcome when you run your code? 运行代码的结果是什么? What are you trying to achieve? 您想达到什么目的? As an example, you can send the following data to the printer in your 'write' call. 例如,您可以在“写入”调用中将以下数据发送到打印机。 Assuming your printer is in CPCL mode: 假设您的打印机处于CPCL模式:

thePrinterConn.write("! 0 200 200 210 1\r\nTEXT 4 0 30 30 Hello world\r\nFORM\r\nPRINT\r\n" .getBytes()); 

CPCL manual section 2 page 3: support.zebra.com/cpws/docs/comtec/PROMAN-CPCL_RevY.pdf CPCL手册第2部分第3页:support.zebra.com/cpws/docs/comtec/PROMAN-CPCL_RevY.pdf

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM