简体   繁体   中英

How to print an image to a MZ220 Printer from Android application?

I have a Zebra MZ220 portable Bluetooth printer.

currently i am able to print text/string on the printer through my android application using the following code...

private static void sendZplOverBluetooth(final String theBtMacAddress, final String Data) {
        new Thread(new Runnable() {
            public void run() {
                try {
                   ZebraPrinterConnection thePrinterConn = new BluetoothPrinterConnection(theBtMacAddress);
                   Looper.prepare();
                   thePrinterConn.open();
                   String zplData = Data;
                   thePrinterConn.write(zplData.getBytes());
                   Thread.sleep(500);
                   thePrinterConn.close();
                   Looper.myLooper().quit();
                } 
                catch (Exception e) {
                   e.printStackTrace();
                }
           }
       }).start();

}

I want to know if there is a way i can print an image on the printer through my android application, if so how? The image is stored on the SD card. Any assistance? Thanks

Yes there is! Check out the Developer demos that came developer demos that came with the SDK

<install_dir>\android\<version>\demos\src\com\zebra\android\devdemo\imageprint\ImagePrintDemo.java

Here is how you get a Bitmap:

BitmapFactory.decodeFile(file.getAbsolutePath())

and you can pass that to the printer via

getGraphicsUtil().printImage(pathOnPrinter, bitmap, [x], [y])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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