开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜