2011-03-09 95 views
3

我有一台Zebra MZ220便携式蓝牙打印机。如何从Android应用程序打印图像到MZ220打印机?

目前我能够通过使用下面的代码我的Android应用程序中的打印机上打印的文本/串...

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(); 

}

我想知道是否有办法,我可以如何通过我的android应用程序在打印机上打印图像?图像存储在SD卡上。有任何帮助?谢谢

回答

3

是的!检查出来,随着SDK

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

这里来了开发商演示了开发者演示是你如何得到一个位图:

BitmapFactory.decodeFile(file.getAbsolutePath())

,你可以通过它打印到打印机

getGraphicsUtil()。printImage(pathOnPrinter,b itmap,[x],[y])

+0

这与您的打印机配置如何执行FormFeed有关。像这样的东西只会在打印作业后送入纸张50毫米:!实用程序 毫微微米 SETFF 50 2.5 打印。有关更多信息,请参阅CPCL手册中的SETFF命令。不要忘记(\ r \ n)打印机需要它们确认命令。你可以使用SDK来发送命令。请参阅getToolsUtil()。sendCommand() – 2011-03-10 13:12:17

+0

可否请你给我下载的斑马(jar文件)sdk和演示的确切链接,我在Mac OSX – Houcine 2013-02-27 09:27:22

+0

没关系,我问朋友安装exe sdk文件并将我发回安装的文件夹,并且我找到了sdk,jar,demo,docs ..谢谢无论如何;) – Houcine 2013-02-27 10:26:40

相关问题