Beginner
Beginner

Reputation: 29573

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

Upvotes: 3

Views: 3828

Answers (1)

Ovi Tisler
Ovi Tisler

Reputation: 6473

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])

Upvotes: 3

Related Questions