package zpSDK.zpSDK; import android.graphics.Bitmap; public interface PrinterInterface { public static final int MSG_CONNECT_START = 0x01; public static final int MSG_CONNECT_ING = 0x02; public static final int MSG_CONNECT_FINISH = 0x03; public static final int MSG_DISCONNECTED = 0x04; public enum BarcodeType { JAN3_EAN13, JAN8_EAN8, CODE39, CODE93, CODE128, CODABAR, ITF, UPC_A, UPC_E, EAN13Plus2, EAN13Plus5, EAN8Plus2, EAN8Plus5, UPCAPlus2, UPCAPlus5, UPCEPlus2, UPCEPlus5, Postnet, MSI, QR; } public enum PrintManufacturer { 自己设备返回的字符串 } /** * 连接蓝牙打印机 * @param address mac地址 * 成功返回true,失败返回false */ public abstract boolean connect(String address); /** * 关闭与打印机的连接 */ public abstract void disconnect(); /** * 页模式下打印页面 * * @param horizontal * 0:正常打印,不旋转;1:整个页面顺时针旋转180°后,打印 * @param skip * 0:打印技术后不定位,直接停止;1:打印结束后定位到标签分割线,如果无缝隙,最大进纸30mm后停止 * @return 操作结果 0:发送成功;非0:请查询错误列表 */ public abstract void print(int horizontal,int skip); /** * 设置打印纸张大小(打印区域)的大小 * @param pageWidth 打印区域宽度 * @param pageHeight 打印区域高度 */ public abstract void pageSetup(int pageWidth, int pageHeight); /** * 边框 * @param lineWidth 边框线条宽度 * @param top_left_x 矩形框左上角x坐标 * @param top_left_y 矩形框左上角y坐标 * @param bottom_right_x 矩形框右下角x坐标 * @param bottom_right_y 矩形框右下角y坐标 */ public abstract void drawBox(int lineWidth, int top_left_x, int top_left_y, int bottom_right_x, int bottom_right_y); /** * 线条 * @param lineWidth 线条宽度 * @param start_x 线条起始点x坐标 * @param start_y 线条起始点y坐标 * @param end_x 线条结束点x坐标 * @param end_y 线条结束点y坐标 * @param fullline true:实线 false:?虚线 */ public abstract void drawLine(int lineWidth, int start_x, int start_y, int end_x, int end_y,boolean fullline); /** 打印文字 * * @param x * 起始横坐标 * @param y * 起始纵坐标 * @param text * 字符串 * @param fontsize * 字体大小 1:16点阵;2:24点阵;3:32点阵;4:24点阵放大一倍;5:32点阵放大一倍 * 6:24点阵放大两倍;7:32点阵放大两倍;其他:24点阵 * @param rotate * 旋转角度 0:不旋转;1:90度;2:180°;3:270° * @param bold * 是否粗体 0:取消;1:设置 * @param underline * 是有有下划线 false:没有;true:有 * @param reverse * 是否反白 false:不反白;true:反白 * */ public abstract void drawText(int text_x, int text_y, String text, int fontSize, int rotate,int bold, boolean reverse, boolean underline); /** * * 页模式下添加文本框(支持自动换行) * * 如果需要设置对齐方式,计算坐标时就需要知道文字区域的大小 以下四个参数就是文字区域的坐标 * @param text_x 文字起始x坐标 * @param text_y 文字起始y坐标 * @param width 文本框宽度 * @param height 文本框高度 * @param text 文本内容 * @param fontSize 字体大小 * @param rotate 旋转度数 * @param bold 加粗 * @param reverse 反显 * @param underline 下划线 * */ public abstract void drawText(int text_x, int text_y, int width, int height, String str, int fontsize,int rotate ,int bold, boolean underline, boolean reverse) ; /** * 页模式下绘制一维条码 * * @param x * 打印的起始横坐标 * @param y * 打印的起始纵坐标 * @param str * 字符串 * @param barcodetype * 条码类型 * 0:CODE39;1:CODE128;2:CODE93;3:CODEBAR;4:EAN8;5:EAN13;6:UPCA * ;7:UPC-E;8:ITF * @param rotate * 旋转角度 0:不旋转;1:90度;2:180°;3:270° * @param barWidth * 条码宽度 * @param barHeight * 条码高度 * @throws UnsupportedEncodingException */ public abstract void drawBarCode(int start_x, int start_y, String text, int type, int rotate,int linewidth, int height); /** * 二维码 * @param start_x 二维码起始位置 * @param start_y 二维码结束位置 * @param text 二维码内容 * @param rotate 旋转角度 * @param ver : QrCode宽度(2-6) * @param lel : QrCode纠错等级(0-20) */ public abstract void drawQrCode(int start_x, int start_y, String text, int rotate, int ver, int lel); /** * 图片 * @param start_x 图片起始点x坐标 * @param start_y 图片起始点y坐标 * @param bmp_size_x 图片的宽度 * @param bmp_size_y 图片的高度 * @param bmp 图片 */ public abstract void drawGraphic(int start_x, int start_y, int bmp_size_x, int bmp_size_y, Bitmap bmp); / ***** 检测打印机状态 用在print(,)方法之后 *******/ zpSDK.printerStatus(); int a=zpSDK.GetStatus(); if(a==-1) { //"获取状态异常------"; Toast.makeText(this,"获取状态异常-----", Toast.LENGTH_LONG).show(); } if(a==1) {//"缺纸----------"; Toast.makeText(this,"缺纸----------", Toast.LENGTH_LONG).show(); } if(a==2) { //"开盖----------"; Toast.makeText(this,"开盖----------", Toast.LENGTH_LONG).show(); } if(a==0) { //"打印机正常-------"; Toast.makeText(this,"打印机正常-------", Toast.LENGTH_LONG).show(); } }