在上述答复中提到的代码使用ZebraPrinterLegacyDelegator,其被弃用。
使用下面的代码,
InputStream inputStream = assetManager.open("printing/ic_launcher.png");
ZebraImageI zebraImageI = ZebraImageFactory.getImage(BitmapFactory.decodeStream(inputStream));
zebraPrinter.printImage(zebraImageI, 250, 0, 0, -1, false);
Zebra打印机实例可以如下创建,
zebraPrinter = ZebraPrinterFactory.getInstance(printerConnection);
printImage参数如下,
image - the image to be printed.
x - horizontal starting position in dots.
y - vertical starting position in dots.
width - desired width of the printed image. Passing a value less than 1 will preserve original width.
height - desired height of the printed image. Passing a value less than 1 will preserve original height.
insideFormat - boolean value indicating whether this image should be printed by itself (false), or is part of a format being written to the connection (true).
而且还解决您的对齐问题会更改x值以将图像移动到您方便的位置。
但我有一些对齐问题。我上面提到的代码在图纸的左侧打印图像。我需要将其与中心对齐。建议我任何想法。 – ajantha 2014-10-08 04:55:32