简体   繁体   中英

Zebra EM 220, print image using Android

I'd like to print an image from my sd card with a Zebra EM220. I tried to use GraphicsUtil.printImage("image path", 0, 0) but all my attempts failed and I'm just able to print a list of characters.

In a first time, I tried to use that :

ZebraPrinter zp = ZebraPrinterFactory.getInstance(printerCo);
zp.getGraphicsUtil().printImage(path, 0, 0);

But the result was a ZebraLanguageUnknownException.
So I followed this solution : https://km.zebra.com/kb/index?page=content&id=SO8239&actp=LIST_RECENT but just a list of characters was printed.

I have no idea how to solve the problem so if someone succeeded to print an image with the Zebra EM 220 and can share the code, it should help me.

My code :

public void print(){
    String path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/myimage.jpg";
    ZebraPrinterConnection printerCo = new BluetoothPrinterConnection(printerMacAdress);
    try {
        printerCo.open();
        if (printerCo.isConnected()){
            ZebraPrinter zp = new ZebraPrinterCpcl(printerCo);
            zp.getGraphicsUtil().printImage(path, 0, 0);
            Thread.sleep(500);
        }               
    } catch (ZebraPrinterConnectionException e) {
        e.printStackTrace();
    } catch (InterruptedException e) {
        e.printStackTrace();
    } finally {
        try{
            // Close the connection to release resources.
            printerCo.close();
        } catch (ZebraPrinterConnectionException e) {
            e.printStackTrace();
        }
    }
}

}

Are you using the ZebraLink SDK? If so, it does not support the EM220. The ZebraLink SDK is designed for use with CPCL and ZPL printers. You can see the list of supported printers here: (click the compatible printers link in the middle): http://www.zebra.com/us/en/products-services/software/adapt-software/zebralink-sdk-android.html#mainpartabscontainer_71ac=downloads .

For the EM 220, you should instead use Zebra's EM 220 SDK for Android (bottom link): http://www.zebra.com/us/en/support-downloads/mobile/em-220.html .

And here is a quick piece of sample code (from Zebra's knowledgebase) explaining one method of printing through this SDK to an EM 220: https://km.zebra.com/kb/index?page=answeropen&type=open&searchid=1363808738897&answerid=16777216&iqaction=5&url=https%3A%2F%2Fkm.zebra.com%2Fkb%2Findex%3Fpage%3Dcontent%26id%3DSA316%26actp%3Dsearch%26viewlocale%3Den_US&highlightinfo=4194576,157,181# .

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