How to print the image on the MZ220 printer from the Android application?

I have a Zebra MZ220 portable Bluetooth printer.

Currently, I can print text / line on a printer through an Android app 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 to print the image on the printer through the Android application, if so, how? The image is saved on the SD card. Any help? thank

+3
source share
1 answer

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

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

Here's how you get a bitmap:

BitmapFactory.decodeFile (file.getAbsolutePath ())

and you can transfer this to a printer using

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

+3

All Articles