Commit eb5a9693 authored by pengguangpu's avatar pengguangpu

测试发现商米机器的打印竟然可以使用桑达的打印驱动

parent 641ec581
...@@ -4,7 +4,6 @@ import android.app.Activity; ...@@ -4,7 +4,6 @@ import android.app.Activity;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.os.Bundle; import android.os.Bundle;
import android.print.PrintManager;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
...@@ -15,8 +14,7 @@ import android.widget.TextView; ...@@ -15,8 +14,7 @@ import android.widget.TextView;
import com.miya.print.IPrinter; import com.miya.print.IPrinter;
import com.miya.print.PrinterManager; import com.miya.print.PrinterManager;
import com.miya.print.PrinterStatusEnum; import com.miya.print.PrinterStatusEnum;
import com.miya.print.utils.BitmapUtils; import com.miya.print.utils.Page80MmPrintUtils;
import com.miya.print.utils.Page88MmPrintUtils;
public class PrintActivity extends Activity implements View.OnClickListener { public class PrintActivity extends Activity implements View.OnClickListener {
...@@ -254,7 +252,7 @@ public class PrintActivity extends Activity implements View.OnClickListener { ...@@ -254,7 +252,7 @@ public class PrintActivity extends Activity implements View.OnClickListener {
ret = printer.printText(-1, 0, "中百", true); ret = printer.printText(-1, 0, "中百", true);
ret = printer.printText(-1, 0, "支付宝自助收银", true); ret = printer.printText(-1, 0, "支付宝自助收银", true);
//分割线 //分割线
ret = printer.printText(-1, 0, Page88MmPrintUtils.printDivideLineString(), true); ret = printer.printText(-1, 0, Page80MmPrintUtils.printDivideLineString(), true);
//居左打印 //居左打印
ret = printer.setAlign(IPrinter.ALIGN_LEFT); ret = printer.setAlign(IPrinter.ALIGN_LEFT);
//订单号 //订单号
...@@ -266,24 +264,24 @@ public class PrintActivity extends Activity implements View.OnClickListener { ...@@ -266,24 +264,24 @@ public class PrintActivity extends Activity implements View.OnClickListener {
//打印时间 //打印时间
ret = printer.printText(-1, 0, "打印时间:2019-01-10 15:16:27", true); ret = printer.printText(-1, 0, "打印时间:2019-01-10 15:16:27", true);
//分割线 //分割线
ret = printer.printText(-1, 0, Page88MmPrintUtils.printDivideLineString(), true); ret = printer.printText(-1, 0, Page80MmPrintUtils.printDivideLineString(), true);
//四条目打印 //四条目打印
ret = printer.printText(-1, 0, Page88MmPrintUtils.printFourData("商品名称", "编码", "数量", "金额"), true); ret = printer.printText(-1, 0, Page80MmPrintUtils.printFourData("商品名称", "编码", "数量", "金额"), true);
//商品名称 //商品名称
ret = printer.printText(-1, 0, "中号购物袋520**(300+80)", true); ret = printer.printText(-1, 0, "中号购物袋520**(300+80)", true);
//三条目打印 //三条目打印
ret = printer.printText(-1, 0, Page88MmPrintUtils.printFourData("6924160298876", " ", "*1", "0.20元"), true); ret = printer.printText(-1, 0, Page80MmPrintUtils.printFourData("6924160298876", " ", "*1", "0.20元"), true);
ret = printer.feedPaper(); ret = printer.feedPaper();
//分割线 //分割线
ret = printer.printText(-1, 0, Page88MmPrintUtils.printDivideLineString(), true); ret = printer.printText(-1, 0, Page80MmPrintUtils.printDivideLineString(), true);
//总件数 //总件数
ret = printer.printText(-1, 0, Page88MmPrintUtils.printTwoData("总件数:", "1"), true); ret = printer.printText(-1, 0, Page80MmPrintUtils.printTwoData("总件数:", "1"), true);
//商品合计 //商品合计
ret = printer.printText(-1, 0, Page88MmPrintUtils.printTwoData("商品合计:", "0.20"), true); ret = printer.printText(-1, 0, Page80MmPrintUtils.printTwoData("商品合计:", "0.20"), true);
//支付宝实付 //支付宝实付
ret = printer.printText(-1, 0, Page88MmPrintUtils.printTwoData("支付宝", "0.01"), true); ret = printer.printText(-1, 0, Page80MmPrintUtils.printTwoData("支付宝", "0.01"), true);
//分割线 //分割线
ret = printer.printText(-1, 0, Page88MmPrintUtils.printDivideLineString(), true); ret = printer.printText(-1, 0, Page80MmPrintUtils.printDivideLineString(), true);
ret = printer.setAlign(IPrinter.ALIGN_CENTER); ret = printer.setAlign(IPrinter.ALIGN_CENTER);
//小票尾部 //小票尾部
ret = printer.printText(-1, 0, "欢迎下次光临!!!", true); ret = printer.printText(-1, 0, "欢迎下次光临!!!", true);
......
...@@ -39,7 +39,10 @@ dependencies { ...@@ -39,7 +39,10 @@ dependencies {
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
//一些工具类集合,从主工程拷贝过来的 //一些工具类集合,从主工程拷贝过来的
implementation 'com.blankj:utilcode:1.16.0' // implementation 'com.blankj:utilcode:1.16.0'
//zxing
implementation files('libs/core-3.3.0.jar')
/** /**
* 创捷机器打印jar包 * 创捷机器打印jar包
......
package com.hisense.hs650service.aidl;
import com.hisense.hs650service.aidl.Printer;
import com.hisense.hs650service.aidl.LedStripe;
interface HS650Api {
Printer getPrinter();
LedStripe getLedStripe();
}
package com.hisense.hs650service.aidl;
interface LedStripe {
void lightOn();
void lightOff();
}
package com.hisense.hs650service.aidl;
interface Printer{
//printer
int initPrinter(int type);
int printTextStr(String text,int fontSize,int pattern);
int printImage(in Bitmap bitmap, int mode);
int feedPaper(int value,int unit);
int printerConfig(int baudrate,int uartPort,boolean ctrlOPen);
int printBar(String barcode);
int printQR(String barcode,int mode);
void closePrinter();
void cutPaper();
int printSend(in byte[] data,int len);
int printStatus();
String getPrnType(int baudrate,int uartPort,int timeout);
}
\ No newline at end of file
// IPrinterService.aidl
package com.sunmi.extprinterservice;
// Declare any non-default types here with import statements
interface ExtPrinterService {
int sendRawData(in byte[] cmd);
int printerInit();
int getPrinterStatus();
int lineWrap(in int n);
int pixelWrap(in int n);
int flush();
int tab();
int printText(in String text);
int printBarCode(in String code, in int type, in int width, in int height, in int hriPos);
int printQrCode(in String code, in int modeSize, in int errorlevel);
int printBitmap(in Bitmap bitmap, in int mode);
int setHorizontalTab(in int[] k);
int setAlignMode(in int type);
int cutPaper(in int m, in int n);
int setFontZoom(in int hori, in int veri);
int printColumnsText(in String[] colsTextArr, in int[] colsWidthArr, in int[] colsAlign);
}
package com.miya.print;
public class HisensePrinter extends BasePrinter {
final static String TAG = HisensePrinter.class.getSimpleName();
}
...@@ -17,7 +17,7 @@ public class PrinterManager { ...@@ -17,7 +17,7 @@ public class PrinterManager {
enum Type { enum Type {
//这里添加扩展的驱动 //这里添加扩展的驱动
// TYPE_HISENSE("hisense", ChuangjiePrinter.class.getName()), // TYPE_HISENSE("hisense", ChuangjiePrinter.class.getName()),
// TYPE_SUNMI("shangmi", ChuangjiePrinter.class.getName()), TYPE_SUNMI("shangmik1", ShangmiK1Printer.class.getName()),
TYPE_YINGTAI("yingtai", YingtaiPrinter.class.getName()), TYPE_YINGTAI("yingtai", YingtaiPrinter.class.getName()),
TYPE_CHUANGJIE("chuangjie", ChuangjiePrinter.class.getName()), TYPE_CHUANGJIE("chuangjie", ChuangjiePrinter.class.getName()),
TYPE_SANGDA("sangda", SangdaPrinter.class.getName()); TYPE_SANGDA("sangda", SangdaPrinter.class.getName());
......
package com.miya.print;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.graphics.Bitmap;
import android.os.IBinder;
import android.os.RemoteException;
import com.miya.print.exception.PrinterException;
import com.miya.print.utils.BytesUtil;
import com.miya.print.utils.ESCUtil;
import com.sunmi.extprinterservice.ExtPrinterService;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
class ShangmiK1Printer extends BasePrinter {
final static String TAG = ShangmiK1Printer.class.getSimpleName();
private ServiceConnection connService = new ServiceConnection() {
@Override
public void onServiceDisconnected(ComponentName name) {
extPrinterService = null;
}
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
extPrinterService = ExtPrinterService.Stub.asInterface(service);
}
};
@Override
public boolean init(Context context) {
return super.init(context);
}
@Override
public boolean release() {
return super.release();
}
private static final String SERVICE_PACKAGE = "com.sunmi.extprinterservice";
private static final String SERVICE_ACTION = "com.sunmi.extprinterservice.PrinterService";
private ExtPrinterService extPrinterService;
/**
* 连接服务
*
* @param context context
*/
@Deprecated
public void connectPrinterService(Context context) {
this.context = context.getApplicationContext();
Intent intent = new Intent();
intent.setPackage(SERVICE_PACKAGE);
intent.setAction(SERVICE_ACTION);
context.getApplicationContext().startService(intent);
context.getApplicationContext().bindService(intent, connService, Context.BIND_AUTO_CREATE);
}
/**
* 断开服务
*
* @param context context
*/
@Deprecated
public void disconnectPrinterService(Context context) {
if (extPrinterService != null) {
context.getApplicationContext().unbindService(connService);
extPrinterService = null;
}
}
@Deprecated
public boolean isConnect() {
return extPrinterService != null;
}
@Deprecated
public void LF() {
if (extPrinterService == null) {
throw new PrinterException(PrinterStatusEnum.CODE_FAILED.status, "服务已断开!");
}
try {
extPrinterService.lineWrap(1);
} catch (RemoteException e) {
throw new PrinterException(PrinterStatusEnum.CODE_FAILED.status, e.getMessage());
}
}
@Deprecated
public void cutPage() {
if (extPrinterService == null) {
throw new PrinterException(PrinterStatusEnum.CODE_FAILED.status, "服务已断开!");
}
try {
extPrinterService.cutPaper(0, 0);
} catch (RemoteException e) {
throw new PrinterException(PrinterStatusEnum.CODE_FAILED.status, e.getMessage());
}
}
@Deprecated
public void setAlignMode(int mode) {
if (extPrinterService == null) {
throw new PrinterException(PrinterStatusEnum.CODE_FAILED.status, "服务已断开!");
}
try {
extPrinterService.setAlignMode(mode);
} catch (RemoteException e) {
throw new PrinterException(PrinterStatusEnum.CODE_FAILED.status, e.getMessage());
}
}
/**
* 设置打印浓度
*/
private int[] darkness = new int[]{0x0600, 0x0500, 0x0400, 0x0300, 0x0200, 0x0100, 0,
0xffff, 0xfeff, 0xfdff, 0xfcff, 0xfbff, 0xfaff};
public void setDarkness(int index) {
if (extPrinterService == null) {
throw new PrinterException(PrinterStatusEnum.CODE_FAILED.status, "服务已断开!");
}
int k = darkness[index];
try {
extPrinterService.sendRawData(ESCUtil.setPrinterDarkness(k));
} catch (RemoteException e) {
throw new PrinterException(PrinterStatusEnum.CODE_FAILED.status, e.getMessage());
}
}
/**
* 初始化打印机
*/
@Deprecated
public void initPrinter() {
if (extPrinterService == null) {
return;
}
try {
extPrinterService.printerInit();
} catch (RemoteException e) {
}
}
/**
* 打印二维码
*/
@Deprecated
public void printQr(String data, int modulesize, int errorlevel) {
if (extPrinterService == null) {
throw new PrinterException(PrinterStatusEnum.CODE_FAILED.status, "服务已断开!");
}
try {
extPrinterService.setAlignMode(1);
extPrinterService.printQrCode(data, modulesize, errorlevel);
extPrinterService.lineWrap(2);
} catch (RemoteException e) {
throw new PrinterException(PrinterStatusEnum.CODE_FAILED.status, e.getMessage());
}
}
/**
* 打印条形码 symbology条码类型
*/
@Deprecated
public void printBarCode(String code, int type, int width, int height, int hriPos) {
if (extPrinterService == null) {
throw new PrinterException(PrinterStatusEnum.CODE_FAILED.status, "服务已断开!");
}
try {
extPrinterService.printBarCode(code, type, width, height, hriPos);
extPrinterService.lineWrap(2);
} catch (RemoteException e) {
throw new PrinterException(PrinterStatusEnum.CODE_FAILED.status, e.getMessage());
}
}
/**
* 打印一维条形码
* data 条码内容
* height 条码高度
* width 条码宽度
* textposition 条码内容位置
*/
@Deprecated
public void printLongBarCode(String data, int height, int width, int textposition) throws RemoteException, IOException {
if (width < 2 || width > 6) {
width = 2;
}
if (textposition < 0 || textposition > 3) {
textposition = 0;
}
if (height < 1 || height > 255) {
height = 162;
}
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
buffer.write(new byte[]{0x1D, 0x48, (byte) textposition,
0x1D, 0x77, (byte) width, 0x1D, 0x68, (byte) height, 0x0A});
byte[] barcode;
barcode = BytesUtil.getBytesFromDecString(data);
buffer.write(new byte[]{0x1D, 0x6B, 0x49, (byte) (barcode.length + 2), 0x7B, (byte) (0x43)});
buffer.write(barcode);
extPrinterService.sendRawData(buffer.toByteArray());
}
/**
* 打印文字
*/
@Deprecated
public void printText(String content, float size, boolean isBold, boolean isUnderLine) {
if (extPrinterService == null) {
throw new PrinterException(PrinterStatusEnum.CODE_FAILED.status, "服务已断开!");
}
try {
if (isBold) {
extPrinterService.sendRawData(ESCUtil.boldOn());
} else {
extPrinterService.sendRawData(ESCUtil.boldOff());
}
if (isUnderLine) {
extPrinterService.sendRawData(ESCUtil.underlineWithOneDotWidthOn());
} else {
extPrinterService.sendRawData(ESCUtil.underlineOff());
}
extPrinterService.printText(content);
} catch (RemoteException e) {
throw new PrinterException(PrinterStatusEnum.CODE_FAILED.status, e.getMessage());
}
}
/*
*打印图片
*/
@Deprecated
public void printBitmap(Bitmap bitmap) {
if (extPrinterService == null) {
throw new PrinterException(PrinterStatusEnum.CODE_FAILED.status, "服务已断开!");
}
try {
extPrinterService.setAlignMode(1);
extPrinterService.printBitmap(bitmap, 0);
extPrinterService.lineWrap(2);
} catch (RemoteException e) {
throw new PrinterException(PrinterStatusEnum.CODE_FAILED.status, e.getMessage());
}
}
@Deprecated
public String updatePrinterState() throws RemoteException {
if (extPrinterService == null) {
return "打印服务已断开!";
}
int state = extPrinterService.getPrinterStatus();
if (state == -1) {
return "打印机脱机或打印服务还未连接打印机";
}
if (state == 0) {
return "正常";
}
if (state == 1) {
return "打印机开盖";
}
if (state == 2) {
return "打印机缺纸";
}
if (state == 3) {
return "打印机即将缺纸";
}
if (state == 4) {
return "打印机过热";
}
return "获取状态异常";
}
/*
* 空打三行!
*/
@Deprecated
public void print3Line() {
if (extPrinterService == null) {
throw new PrinterException(PrinterStatusEnum.CODE_FAILED.status, "服务已断开!");
}
try {
extPrinterService.lineWrap(3);
} catch (RemoteException e) {
throw new PrinterException(PrinterStatusEnum.CODE_FAILED.status, e.getMessage());
}
}
@Deprecated
public void sendRawData(byte[] data) {
if (extPrinterService == null) {
throw new PrinterException(PrinterStatusEnum.CODE_FAILED.status, "服务已断开!");
}
try {
extPrinterService.sendRawData(data);
} catch (RemoteException e) {
throw new PrinterException(PrinterStatusEnum.CODE_FAILED.status, e.getMessage());
}
}
}
package com.miya.print.utils;
import android.annotation.SuppressLint;
import android.graphics.Bitmap;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter;
import java.util.Hashtable;
public class BytesUtil {
//字节流转16进制字符串
public static String getHexStringFromBytes(byte[] data) {
if (data == null || data.length <= 0) {
return null;
}
String hexString = "0123456789ABCDEF";
int size = data.length * 2;
StringBuilder sb = new StringBuilder(size);
for (int i = 0; i < data.length; i++) {
sb.append(hexString.charAt((data[i] & 0xF0) >> 4));
sb.append(hexString.charAt((data[i] & 0x0F) >> 0));
}
return sb.toString();
}
//单字符转字节
private static byte charToByte(char c) {
return (byte) "0123456789ABCDEF".indexOf(c);
}
//16进制字符串转字节数组
@SuppressLint("DefaultLocale")
public static byte[] getBytesFromHexString(String hexstring){
if(hexstring == null || hexstring.equals("")){
return null;
}
hexstring = hexstring.replace(" ", "");
hexstring = hexstring.toUpperCase();
int size = hexstring.length()/2;
char[] hexarray = hexstring.toCharArray();
byte[] rv = new byte[size];
for(int i=0; i<size; i++){
int pos = i * 2;
rv[i] = (byte) (charToByte(hexarray[pos]) << 4 | charToByte(hexarray[pos + 1]));
}
return rv;
}
//十进制字符串转字节数组
@SuppressLint("DefaultLocale")
public static byte[] getBytesFromDecString(String decstring){
if(decstring == null || decstring.equals("")){
return null;
}
decstring = decstring.replace(" ", "");
int size = decstring.length()/2;
char[] decarray = decstring.toCharArray();
byte[] rv = new byte[size];
for(int i=0; i<size; i++){
int pos = i * 2;
rv[i] = (byte) (charToByte(decarray[pos])*10 + charToByte(decarray[pos + 1]));
}
return rv;
}
//字节数组组合操作1
public static byte[] byteMerger(byte[] byte_1, byte[] byte_2) {
byte[] byte_3 = new byte[byte_1.length + byte_2.length];
System.arraycopy(byte_1, 0, byte_3, 0, byte_1.length);
System.arraycopy(byte_2, 0, byte_3, byte_1.length, byte_2.length);
return byte_3;
}
//字节数组组合操作2
public static byte[] byteMerger(byte[][] byteList) {
int length = 0;
for (int i = 0; i < byteList.length; i++) {
length += byteList[i].length;
}
byte[] result = new byte[length];
int index = 0;
for (int i = 0; i < byteList.length; i++) {
byte[] nowByte = byteList[i];
for (int k = 0; k < byteList[i].length; k++) {
result[index] = nowByte[k];
index++;
}
}
for (int i = 0; i < index; i++) {
// CommonUtils.LogWuwei("", "result[" + i + "] is " + result[i]);
}
return result;
}
//生成表格字节流
public static byte[] initTable(int h, int w) {
int hh = h * 32;
int ww = w * 4;
byte[] data = new byte[hh * ww + 5];
data[0] = (byte) ww;//xL
data[1] = (byte) (ww >> 8);//xH
data[2] = (byte) hh;
data[3] = (byte) (hh >> 8);
int k = 4;
int m = 31;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
data[k++] = (byte) 0xFF;
data[k++] = (byte) 0xFF;
data[k++] = (byte) 0xFF;
data[k++] = (byte) 0xFF;
}
if (i == h - 1) m = 30;
for (int t = 0; t < m; t++) {
for (int j = 0; j < w - 1; j++) {
data[k++] = (byte) 0x80;
data[k++] = (byte) 0;
data[k++] = (byte) 0;
data[k++] = (byte) 0;
}
data[k++] = (byte) 0x80;
data[k++] = (byte) 0;
data[k++] = (byte) 0;
data[k++] = (byte) 0x01;
}
}
for (int j = 0; j < w; j++) {
data[k++] = (byte) 0xFF;
data[k++] = (byte) 0xFF;
data[k++] = (byte) 0xFF;
data[k++] = (byte) 0xFF;
}
data[k++] = 0x0A;
return data;
}
/**
* 生成二维码字节流
*
* @param data
* @param size
* @return
*/
public static byte[] getZXingQRCode(String data, int size) {
try {
Hashtable<EncodeHintType, String> hints = new Hashtable<EncodeHintType, String>();
hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
//图像数据转换,使用了矩阵转换
BitMatrix bitMatrix = new QRCodeWriter().encode(data, BarcodeFormat.QR_CODE, size, size, hints);
//System.out.println("bitmatrix height:" + bitMatrix.getHeight() + " width:" + bitMatrix.getWidth());
return getBytesFromBitMatrix(bitMatrix);
} catch (WriterException e) {
e.printStackTrace();
}
return null;
}
public static byte[] getBytesFromBitMatrix(BitMatrix bits) {
if (bits == null) return null;
int h = bits.getHeight();
int w = (bits.getWidth() + 7) / 8;
byte[] rv = new byte[h * w + 4];
rv[0] = (byte) w;//xL
rv[1] = (byte) (w >> 8);//xH
rv[2] = (byte) h;
rv[3] = (byte) (h >> 8);
int k = 4;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
for (int n = 0; n < 8; n++) {
byte b = getBitMatrixColor(bits, j * 8 + n, i);
rv[k] += rv[k] + b;
}
k++;
}
}
return rv;
}
private static byte getBitMatrixColor(BitMatrix bits, int x, int y) {
int width = bits.getWidth();
int height = bits.getHeight();
if (x >= width || y >= height || x < 0 || y < 0) return 0;
if (bits.get(x, y)) {
return 1;
} else {
return 0;
}
}
/**
* 将bitmap图转换为头四位有宽高的光栅位图
*/
public static byte[] getBytesFromBitMap(Bitmap bitmap) {
int width = bitmap.getWidth();
int height = bitmap.getHeight();
int bw = (width - 1) / 8 + 1;
byte[] rv = new byte[height * bw + 4];
rv[0] = (byte) bw;//xL
rv[1] = (byte) (bw >> 8);//xH
rv[2] = (byte) height;
rv[3] = (byte) (height >> 8);
int[] pixels = new int[width * height];
bitmap.getPixels(pixels, 0, width, 0, 0, width, height);
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
int clr = pixels[width * i + j];
int red = (clr & 0x00ff0000) >> 16;
int green = (clr & 0x0000ff00) >> 8;
int blue = clr & 0x000000ff;
byte gray = (RGB2Gray(red, green, blue));
rv[(width * i + j) / 8 + 4] = (byte) (rv[(width * i + j) / 8 + 4] | (gray << (7 - ((width * i + j) % 8))));
}
}
return rv;
}
/**
* 将bitmap转成按mode指定的N点行数据
*/
public static byte[] getBytesFromBitMap(Bitmap bitmap, int mode) {
int width = bitmap.getWidth();
int height = bitmap.getHeight();
int[] pixels = new int[width * height];
if (mode == 0 || mode == 1) {
byte[] res = new byte[width * height / 8 + 5 * height / 8];
bitmap.getPixels(pixels, 0, width, 0, 0, width, height);
for (int i = 0; i < height / 8; i++) {
res[0 + i * (width + 5)] = 0x1b;
res[1 + i * (width + 5)] = 0x2a;
res[2 + i * (width + 5)] = (byte) mode;
res[3 + i * (width + 5)] = (byte) (width % 256);
res[4 + i * (width + 5)] = (byte) (width / 256);
for (int j = 0; j < width; j++) {
byte gray = 0;
for (int m = 0; m < 8; m++) {
int clr = pixels[j + width * (i * 8 + m)];
int red = (clr & 0x00ff0000) >> 16;
int green = (clr & 0x0000ff00) >> 8;
int blue = clr & 0x000000ff;
gray = (byte) ((RGB2Gray(red, green, blue) << (7 - m)) | gray);
}
res[5 + j + i * (width + 5)] = gray;
}
}
return res;
} else if (mode == 32 || mode == 33) {
byte[] res = new byte[width * height / 8 + 5 * height / 24];
bitmap.getPixels(pixels, 0, width, 0, 0, width, height);
for (int i = 0; i < height / 24; i++) {
res[0 + i * (width * 3 + 5)] = 0x1b;
res[1 + i * (width * 3 + 5)] = 0x2a;
res[2 + i * (width * 3 + 5)] = (byte) mode;
res[3 + i * (width * 3 + 5)] = (byte) (width % 256);
res[4 + i * (width * 3 + 5)] = (byte) (width / 256);
for (int j = 0; j < width; j++) {
for (int n = 0; n < 3; n++) {
byte gray = 0;
for (int m = 0; m < 8; m++) {
int clr = pixels[j + width * (i * 24 + m + n * 8)];
int red = (clr & 0x00ff0000) >> 16;
int green = (clr & 0x0000ff00) >> 8;
int blue = clr & 0x000000ff;
gray = (byte) ((RGB2Gray(red, green, blue) << (7 - m)) | gray);
}
res[5 + j * 3 + i * (width * 3 + 5) + n] = gray;
}
}
}
return res;
} else {
return new byte[]{0x0A};
}
}
private static byte RGB2Gray(int r, int g, int b) {
return (false ? ((int) (0.29900 * r + 0.58700 * g + 0.11400 * b) > 200)
: ((int) (0.29900 * r + 0.58700 * g + 0.11400 * b) < 200)) ? (byte) 1 : (byte) 0;
}
/**
* 生成间断性黑块数据
*
* @param w : 打印纸宽度, 单位点
* @return
*/
public static byte[] initBlackBlock(int w) {
int ww = (w + 7) / 8;
int n = (ww + 11) / 12;
int hh = n * 24;
byte[] data = new byte[hh * ww + 5];
data[0] = (byte) ww;//xL
data[1] = (byte) (ww >> 8);//xH
data[2] = (byte) hh;
data[3] = (byte) (hh >> 8);
int k = 4;
for (int i = 0; i < n; i++) {
for (int j = 0; j < 24; j++) {
for (int m = 0; m < ww; m++) {
if (m / 12 == i) {
data[k++] = (byte) 0xFF;
} else {
data[k++] = 0;
}
}
}
}
data[k++] = 0x0A;
return data;
}
/**
* 生成一大块黑块数据
*
* @param h : 黑块高度, 单位点
* @param w : 黑块宽度, 单位点, 8的倍数
* @return
*/
public static byte[] initBlackBlock(int h, int w) {
int hh = h;
int ww = (w - 1) / 8 + 1;
byte[] data = new byte[hh * ww + 6];
data[0] = (byte) ww;//xL
data[1] = (byte) (ww >> 8);//xH
data[2] = (byte) hh;
data[3] = (byte) (hh >> 8);
int k = 4;
for (int i = 0; i < hh; i++) {
for (int j = 0; j < ww; j++) {
data[k++] = (byte) 0xFF;
}
}
data[k++] = 0x00;
data[k++] = 0x00;
return data;
}
//百度小票
public static byte[] getBaiduTestBytes() {
byte[] rv = new byte[]{
0x1b, 0x40, 0x1b, 0x4d, 0x00, 0x1b, 0x61, 0x00, 0x1d, 0x21, 0x11, 0x1b, 0x45, 0x00, 0x1b, 0x47, 0x00, 0x1b, 0x61, 0x00, 0x1b, 0x45, 0x01, 0x1b, 0x47, 0x01, (byte) 0xb1, (byte) 0xbe
, (byte) 0xb5, (byte) 0xea, (byte) 0xc1, (byte) 0xf4, (byte) 0xb4, (byte) 0xe6, 0x0a, 0x1b, 0x4d, 0x00, 0x1b, 0x61, 0x00, 0x1d, 0x21, 0x00, 0x1b, 0x45, 0x00, 0x1b, 0x47, 0x00, 0x1b, 0x61, 0x00, 0x2a, 0x2a, 0x2a
, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a
, 0x2a, 0x0a
, 0x1b, 0x40, 0x1b, 0x4d, 0x00, 0x1b, 0x61, 0x00, 0x1d, 0x21, 0x11, 0x1b, 0x45, 0x00, 0x1b, 0x47, 0x00, 0x1b, 0x61, 0x00, 0x1b, 0x45, 0x01, 0x1b, 0x47, 0x01, 0x1b, 0x61
, 0x01, 0x23, 0x31, 0x35, 0x20, (byte) 0xb0, (byte) 0xd9, (byte) 0xb6, (byte) 0xc8, (byte) 0xcd, (byte) 0xe2, (byte) 0xc2, (byte) 0xf4, 0x0a, 0x5b, (byte) 0xbb, (byte) 0xf5, (byte) 0xb5, (byte) 0xbd, (byte) 0xb8, (byte) 0xb6, (byte) 0xbf, (byte) 0xee, 0x5d, 0x0a, 0x1b, 0x4d, 0x00
, 0x1b, 0x61, 0x00, 0x1d, 0x21, 0x00, 0x1b, 0x45, 0x00, 0x1b, 0x47, 0x00, 0x1b, 0x61, 0x00, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a
, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x0a
, 0x1b, 0x40, 0x1b, 0x4d, 0x00, 0x1b, 0x61, 0x00, 0x1d, 0x21, 0x01, 0x1b, 0x45, 0x00, 0x1b, 0x47, 0x00, 0x1b, 0x61, 0x00, (byte) 0xc6, (byte) 0xda, (byte) 0xcd, (byte) 0xfb, (byte) 0xcb, (byte) 0xcd, (byte) 0xb4, (byte) 0xef
, (byte) 0xca, (byte) 0xb1, (byte) 0xbc, (byte) 0xe4, (byte) 0xa3, (byte) 0xba, (byte) 0xc1, (byte) 0xa2, (byte) 0xbc, (byte) 0xb4, (byte) 0xc5, (byte) 0xe4, (byte) 0xcb, (byte) 0xcd, 0x0a, (byte) 0xb6, (byte) 0xa9, (byte) 0xb5, (byte) 0xa5, (byte) 0xb1, (byte) 0xb8, (byte) 0xd7, (byte) 0xa2, (byte) 0xa3, (byte) 0xba, (byte) 0xc7, (byte) 0xeb, (byte) 0xcb
, (byte) 0xcd, (byte) 0xb5, (byte) 0xbd, (byte) 0xbf, (byte) 0xfc, (byte) 0xbf, (byte) 0xc6, (byte) 0xce, (byte) 0xf7, (byte) 0xc3, (byte) 0xc5, 0x2c, (byte) 0xb2, (byte) 0xbb, (byte) 0xd2, (byte) 0xaa, (byte) 0xc0, (byte) 0xb1, 0x0a, (byte) 0xb7, (byte) 0xa2, (byte) 0xc6, (byte) 0xb1, (byte) 0xd0, (byte) 0xc5, (byte) 0xcf, (byte) 0xa2, (byte) 0xa3
, (byte) 0xba, (byte) 0xb0, (byte) 0xd9, (byte) 0xb6, (byte) 0xc8, (byte) 0xcd, (byte) 0xe2, (byte) 0xc2, (byte) 0xf4, (byte) 0xb7, (byte) 0xa2, (byte) 0xc6, (byte) 0xb1, 0x0a, 0x1b, 0x4d, 0x00, 0x1b, 0x61, 0x00, 0x1d, 0x21, 0x00, 0x1b, 0x45, 0x00, 0x1b, 0x47
, 0x00, 0x1b, 0x61, 0x00, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a
, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x0a
, 0x1b, 0x40, 0x1b, 0x4d, 0x00, 0x1b, 0x61, 0x00, 0x1d, 0x21, 0x00, 0x1b, 0x45, 0x00, 0x1b, 0x47, 0x00, 0x1b, 0x61, 0x00, (byte) 0xb6, (byte) 0xa9, (byte) 0xb5, (byte) 0xa5, (byte) 0xb1, (byte) 0xe0, (byte) 0xba, (byte) 0xc5
, (byte) 0xa3, (byte) 0xba, 0x31, 0x34, 0x31, 0x38, 0x37, 0x31, 0x38, 0x36, 0x39, 0x31, 0x31, 0x36, 0x38, 0x39, 0x0a, (byte) 0xcf, (byte) 0xc2, (byte) 0xb5, (byte) 0xa5, (byte) 0xca, (byte) 0xb1, (byte) 0xbc, (byte) 0xe4, (byte) 0xa3, (byte) 0xba, 0x32
, 0x30, 0x31, 0x34, 0x2d, 0x31, 0x32, 0x2d, 0x31, 0x36, 0x20, 0x31, 0x36, 0x3a, 0x33, 0x31, 0x0a, 0x1b, 0x4d, 0x00, 0x1b, 0x61, 0x00, 0x1d, 0x21, 0x00, 0x1b, 0x45, 0x00
, 0x1b, 0x47, 0x00, 0x1b, 0x61, 0x00, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a
, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x0a
, 0x1b, 0x40, 0x1b, 0x4d, 0x00, 0x1b, 0x61, 0x00, 0x1d, 0x21, 0x01, 0x1b, 0x45, 0x00, 0x1b, 0x47, 0x00, 0x1b, 0x61, 0x00, (byte) 0xb2, (byte) 0xcb, (byte) 0xc6, (byte) 0xb7, (byte) 0xc3, (byte) 0xfb, (byte) 0xb3, (byte) 0xc6
, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, (byte) 0xca, (byte) 0xfd, (byte) 0xc1, (byte) 0xbf, 0x20, 0x20, 0x20, 0x20, 0x20, (byte) 0xbd, (byte) 0xf0, (byte) 0xb6, (byte) 0xee, 0x0a, 0x1b, 0x4d, 0x00, 0x1b, 0x61
, 0x00, 0x1d, 0x21, 0x00, 0x1b, 0x45, 0x00, 0x1b, 0x47, 0x00, 0x1b, 0x61, 0x00, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d
, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x1b, 0x4d, 0x00, 0x1b, 0x61, 0x00, 0x1d, 0x21, 0x01, 0x1b
, 0x45, 0x00, 0x1b, 0x47, 0x00, 0x1b, 0x61, 0x00, (byte) 0xcf, (byte) 0xe3, (byte) 0xc0, (byte) 0xb1, (byte) 0xc3, (byte) 0xe6, (byte) 0xcc, (byte) 0xd7, (byte) 0xb2, (byte) 0xcd, 0x1b, 0x24, (byte) 0xf2, 0x00, 0x31, 0x1b, 0x24, 0x25, 0x01, (byte) 0xa3
, (byte) 0xa4, 0x34, 0x30, 0x2e, 0x30, 0x30, 0x0a, 0x1b, 0x4d, 0x00, 0x1b, 0x61, 0x00, 0x1d, 0x21, 0x00, 0x1b, 0x45, 0x00, 0x1b, 0x47, 0x00, 0x1b, 0x61, 0x00, 0x1b, 0x4d, 0x00
, 0x1b, 0x61, 0x00, 0x1d, 0x21, 0x00, 0x1b, 0x45, 0x00, 0x1b, 0x47, 0x00, 0x1b, 0x61, 0x00, 0x1b, 0x4d, 0x00, 0x1b, 0x61, 0x00, 0x1d, 0x21, 0x01, 0x1b, 0x45, 0x00, 0x1b
, 0x47, 0x00, 0x1b, 0x61, 0x00, (byte) 0xcb, (byte) 0xd8, (byte) 0xca, (byte) 0xb3, (byte) 0xcc, (byte) 0xec, (byte) 0xcf, (byte) 0xc2, (byte) 0xba, (byte) 0xba, (byte) 0xb1, (byte) 0xa4, 0x1b, 0x24, (byte) 0xf2, 0x00, 0x31, 0x1b, 0x24, 0x25, 0x01, (byte) 0xa3, (byte) 0xa4
, 0x33, 0x38, 0x2e, 0x30, 0x30, 0x0a, 0x1b, 0x4d, 0x00, 0x1b, 0x61, 0x00, 0x1d, 0x21, 0x00, 0x1b, 0x45, 0x00, 0x1b, 0x47, 0x00, 0x1b, 0x61, 0x00, 0x1b, 0x4d, 0x00, 0x1b
, 0x61, 0x00, 0x1d, 0x21, 0x00, 0x1b, 0x45, 0x00, 0x1b, 0x47, 0x00, 0x1b, 0x61, 0x00
, 0x1b, 0x40, 0x1b, 0x4d, 0x00, 0x1b, 0x61, 0x00, 0x1d, 0x21, 0x00, 0x1b, 0x45, 0x00, 0x1b, 0x47, 0x00, 0x1b, 0x61, 0x00, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d
, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a
, 0x1b, 0x40, 0x1b, 0x4d, 0x00, 0x1b, 0x61, 0x00, 0x1d, 0x21, 0x00, 0x1b, 0x45, 0x00, 0x1b, 0x47, 0x00, 0x1b, 0x61, 0x00, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a
, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x0a, 0x1b, 0x4d, 0x00
, 0x1b, 0x61, 0x00, 0x1d, 0x21, 0x01, 0x1b, 0x45, 0x00, 0x1b, 0x47, 0x00, 0x1b, 0x61, 0x00, (byte) 0xd0, (byte) 0xd5, (byte) 0xc3, (byte) 0xfb, (byte) 0xa3, (byte) 0xba, (byte) 0xb0, (byte) 0xd9, (byte) 0xb6, (byte) 0xc8, (byte) 0xb2, (byte) 0xe2, (byte) 0xca
, (byte) 0xd4, 0x0a, (byte) 0xb5, (byte) 0xd8, (byte) 0xd6, (byte) 0xb7, (byte) 0xa3, (byte) 0xba, (byte) 0xbf, (byte) 0xfc, (byte) 0xbf, (byte) 0xc6, (byte) 0xbf, (byte) 0xc6, (byte) 0xbc, (byte) 0xbc, (byte) 0xb4, (byte) 0xf3, (byte) 0xcf, (byte) 0xc3, 0x0a, (byte) 0xb5, (byte) 0xe7, (byte) 0xbb, (byte) 0xb0, (byte) 0xa3, (byte) 0xba, 0x31
, 0x38, 0x37, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x0a
, 0x1b, 0x40, 0x1b, 0x4d, 0x00, 0x1b, 0x61, 0x00, 0x1d, 0x21, 0x00, 0x1b, 0x45, 0x00, 0x1b, 0x47, 0x00, 0x1b, 0x61, 0x00, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a
, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x0a, (byte) 0xb0, (byte) 0xd9, (byte) 0xb6
, (byte) 0xc8, (byte) 0xb2, (byte) 0xe2, (byte) 0xca, (byte) 0xd4, (byte) 0xc9, (byte) 0xcc, (byte) 0xbb, (byte) 0xa7, 0x0a, 0x31, 0x38, 0x37, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x0a, 0x1b, 0x4d, 0x00, 0x1b, 0x61, 0x00, 0x1d
, 0x21, 0x00, 0x1b, 0x45, 0x00, 0x1b, 0x47, 0x00, 0x1b, 0x61, 0x00, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a
, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x0a, 0x1b, 0x4d, 0x00, 0x1b, 0x61, 0x00, 0x1d, 0x21, 0x00, 0x1b, 0x45, 0x00
, 0x1b, 0x47, 0x00, 0x1b, 0x61, 0x00, 0x1b, 0x61, 0x01, 0x23, 0x31, 0x35, 0x20, (byte) 0xb0, (byte) 0xd9, (byte) 0xb6, (byte) 0xc8, (byte) 0xcd, (byte) 0xe2, (byte) 0xc2, (byte) 0xf4, 0x20, 0x20, 0x31, 0x31, (byte) 0xd4, (byte) 0xc2, 0x30
, 0x39, (byte) 0xc8, (byte) 0xd5, 0x20, 0x31, 0x37, 0x3a, 0x35, 0x30, 0x3a, 0x33, 0x30, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a
};
return rv;
}
//美团小票
public static byte[] getMeituanBill() {
byte[] rv = new byte[]{
0x1b, 0x40, 0x1b, 0x61, 0x01, 0x1d, 0x21, 0x11, (byte) 0xa3, (byte) 0xa3, 0x31, 0x20, 0x20, (byte) 0xc3, (byte) 0xc0, (byte) 0xcd, (byte) 0xc5, (byte) 0xb2, (byte) 0xe2, (byte) 0xca, (byte) 0xd4, 0x0a
, 0x0a, 0x1d, 0x21, 0x00, (byte) 0xd4, (byte) 0xc1, (byte) 0xcf, (byte) 0xe3, (byte) 0xb8, (byte) 0xdb, (byte) 0xca, (byte) 0xbd, (byte) 0xc9, (byte) 0xd5, (byte) 0xc0, (byte) 0xb0, 0x28, (byte) 0xb5, (byte) 0xda, 0x31, (byte) 0xc1, (byte) 0xaa
, 0x29, 0x0a, 0x1b, 0x21, 0x10, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d
, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x2a, 0x20, 0x2a, 0x20, 0x2a, 0x20
, 0x2a, 0x20, 0x2a, 0x20, 0x2a, 0x20, 0x20, (byte) 0xd4, (byte) 0xa4, (byte) 0xb6, (byte) 0xa9, (byte) 0xb5, (byte) 0xa5, 0x20, 0x20, 0x2a, 0x20, 0x2a, 0x20, 0x2a, 0x20, 0x2a
, 0x20, 0x2a, 0x20, 0x2a, 0x0a, (byte) 0xc6, (byte) 0xda, (byte) 0xcd, (byte) 0xfb, (byte) 0xcb, (byte) 0xcd, (byte) 0xb4, (byte) 0xef, (byte) 0xca, (byte) 0xb1, (byte) 0xbc, (byte) 0xe4, 0x3a, 0x20, 0x5b, 0x31, 0x38
, 0x3a, 0x30, 0x30, 0x5d, 0x0a, 0x1d, 0x21, 0x00, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d
, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x1b, 0x61, 0x00
, (byte) 0xcf, (byte) 0xc2, (byte) 0xb5, (byte) 0xa5, (byte) 0xca, (byte) 0xb1, (byte) 0xbc, (byte) 0xe4, 0x3a, 0x30, 0x31, 0x2d, 0x30, 0x31, 0x20, 0x31, 0x32, 0x3a, 0x30, 0x30, 0x0a, 0x1b
, 0x21, 0x10, (byte) 0xb1, (byte) 0xb8, (byte) 0xd7, (byte) 0xa2, 0x3a, (byte) 0xb1, (byte) 0xf0, (byte) 0xcc, (byte) 0xab, (byte) 0xc0, (byte) 0xb1, 0x0a, 0x1d, 0x21, 0x00, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d
, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d
, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, (byte) 0xb2, (byte) 0xcb, (byte) 0xc3, (byte) 0xfb, 0x09, 0x09, 0x20, 0x20, 0x20, (byte) 0xca, (byte) 0xfd, (byte) 0xc1, (byte) 0xbf, 0x09, 0x20, 0x20
, 0x20, 0x20, (byte) 0xd0, (byte) 0xa1, (byte) 0xbc, (byte) 0xc6, 0x09, 0x0a, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d
, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x1b, 0x21, 0x10
, (byte) 0xba, (byte) 0xec, (byte) 0xc9, (byte) 0xd5, (byte) 0xc8, (byte) 0xe2, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x78
, 0x31, 0x09, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x31, 0x32, 0x0a, 0x1d, 0x21, 0x00, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d
, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d
, 0x2d, 0x2d, 0x0a, (byte) 0xc5, (byte) 0xe4, (byte) 0xcb, (byte) 0xcd, (byte) 0xb7, (byte) 0xd1, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20
, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x35, 0x0a, (byte) 0xb2, (byte) 0xcd, (byte) 0xba, (byte) 0xd0, (byte) 0xb7, (byte) 0xd1, 0x20, 0x20
, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20
, 0x20, 0x31, 0x0a, 0x5b, (byte) 0xb3, (byte) 0xac, (byte) 0xca, (byte) 0xb1, (byte) 0xc5, (byte) 0xe2, (byte) 0xb8, (byte) 0xb6, 0x5d, 0x20, 0x2d, (byte) 0xcf, (byte) 0xea, (byte) 0xbc, (byte) 0xfb, (byte) 0xb6, (byte) 0xa9, (byte) 0xb5
, (byte) 0xa5, 0x0a, (byte) 0xbf, (byte) 0xc9, (byte) 0xbf, (byte) 0xda, (byte) 0xbf, (byte) 0xc9, (byte) 0xc0, (byte) 0xd6, 0x3a, 0x78, 0x31, 0x0a, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d
, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d
, 0x2d, 0x2d, 0x0a, 0x1b, 0x21, 0x10, (byte) 0xba, (byte) 0xcf, (byte) 0xbc, (byte) 0xc6, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20
, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x31, 0x38, (byte) 0xd4, (byte) 0xaa, 0x0a, 0x1b, 0x40, 0x2d, 0x2d, 0x2d
, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d
, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x1d, 0x21, 0x11, (byte) 0xd5, (byte) 0xc5, 0x2a, 0x20, 0x31, 0x38, 0x33, 0x31, 0x32, 0x33, 0x34
, 0x35, 0x36, 0x37, 0x38, 0x0a, (byte) 0xb5, (byte) 0xd8, (byte) 0xd6, (byte) 0xb7, (byte) 0xd0, (byte) 0xc5, (byte) 0xcf, (byte) 0xa2, 0x0a, 0x1d, 0x21, 0x00, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d
, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d
, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x0a, 0x1b, 0x40, 0x1b, 0x61, 0x01, 0x1d, 0x21, 0x11, (byte) 0xa3, (byte) 0xa3, 0x31, 0x20, 0x20, (byte) 0xc3, (byte) 0xc0
, (byte) 0xcd, (byte) 0xc5, (byte) 0xb2, (byte) 0xe2, (byte) 0xca, (byte) 0xd4, 0x0a, 0x1d, 0x21, 0x00, 0x1b, 0x40, 0x0a, 0x0a, 0x0a, 0x1d, 0x56, 0x00
};
return rv;
}
//饿了么小票
public static byte[] getErlmoData() {
byte[] rv = new byte[]{
0x1b, 0x40, 0x1b, 0x61, 0x00, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x20, 0x1d, 0x21, 0x11, 0x23, 0x31, 0x1d, 0x21, 0x00, 0x00, (byte) 0xb6, (byte) 0xf6
, (byte) 0xc1, (byte) 0xcb, (byte) 0xc3, (byte) 0xb4, (byte) 0xcd, (byte) (byte) 0xe2, (byte) 0xc2, (byte) 0xf4, (byte) 0xb5, (byte) 0xa5, 0x20, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x0a, 0x0a, 0x1b, 0x61
, 0x01, (byte) 0xbf, (byte) 0xa8, (byte) 0xc8, (byte) 0xf8, (byte) 0xc5, (byte) 0xfb, (byte) 0xc8, (byte) 0xf8, 0x0a, 0x0a, 0x1b, 0x61, 0x00, 0x1b, 0x61, 0x01, 0x1d, 0x21, 0x11, 0x2d, 0x2d
, (byte) 0xd2, (byte) 0xd1, (byte) 0xd6, (byte) 0xa7, (byte) 0xb8, (byte) 0xb6, 0x2d, 0x2d, 0x1d, 0x21, 0x00, 0x00, 0x0a, 0x0a, 0x1b, 0x61, 0x00, 0x1b, 0x61, 0x01, 0x1d, 0x21
, 0x11, (byte) 0xd4, (byte) 0xa4, (byte) 0xbc, (byte) 0xc6, 0x31, 0x39, 0x3a, 0x30, 0x30, (byte) 0xcb, (byte) 0xcd, (byte) 0xb4, (byte) (byte) 0xef, 0x1d, 0x21, 0x00, 0x00, 0x0a, 0x0a, 0x1b, 0x61
, 0x00, 0x5b, (byte) 0xcf, (byte) 0xc2, (byte) 0xb5, (byte) 0xa5, (byte) 0xca, (byte) 0xb1, (byte) 0xbc, (byte) (byte) 0xe4, 0x5d, 0x32, 0x30, 0x31, 0x34, 0x2d, 0x31, 0x32, 0x2d, 0x30, 0x33, 0x20
, 0x31, 0x36, 0x3a, 0x32, 0x31, 0x0a, 0x5b, (byte) 0xb1, (byte) 0xb8, (byte) 0xd7, (byte) 0xa2, 0x5d, 0x1d, 0x21, 0x01, (byte) 0xb2, (byte) 0xbb, (byte) 0xb3, (byte) 0xd4, (byte) 0xc0, (byte) 0xb1, 0x20
, (byte) 0xc0, (byte) 0xb1, (byte) 0xd2, (byte) 0xbb, (byte) 0xb5, (byte) (byte) 0xe3, 0x20, (byte) 0xb6, (byte) (byte) 0xe0, (byte) 0xbc, (byte) 0xd3, (byte) 0xc3, (byte) 0xd7, 0x20, (byte) 0xc3, (byte) 0xbb, (byte) 0xc1, (byte) (byte) 0xe3, (byte) 0xc7, (byte) 0xae, 0x1d, 0x21
, 0x00, 0x0a, 0x5b, (byte) 0xb7, (byte) 0xa2, (byte) 0xc6, (byte) 0xb1, 0x5d, (byte) 0xd5, (byte) (byte) 0xe2, (byte) 0xca, (byte) 0xc7, (byte) 0xd2, (byte) 0xbb, (byte) 0xb8, (byte) 0xf6, (byte) 0xb7, (byte) 0xa2, (byte) 0xc6, (byte) 0xb1, (byte) 0xcc, (byte) 0xa7
, (byte) 0xcd, (byte) 0xb7, 0x0a, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d
, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, (byte) 0xb2, (byte) 0xcb, (byte) 0xc3, (byte) 0xfb, 0x20, 0x20, 0x20, 0x20
, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, (byte) 0xca, (byte) 0xfd, (byte) 0xc1, (byte) 0xbf, 0x20, 0x20, (byte) 0xd0, (byte) 0xa1
, (byte) 0xbc, (byte) 0xc6, 0x0a, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x20, 0x31, (byte) 0xba, (byte) 0xc5, (byte) 0xc0, (byte) 0xba, (byte) 0xd7, (byte) 0xd3
, 0x20, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x1d, 0x21, 0x01, (byte) 0xb2, (byte) (byte) 0xe2, (byte) 0xca, (byte) 0xd4, (byte) 0xc3, (byte) 0xc0
, (byte) 0xca, (byte) 0xb3, (byte) 0xd2, (byte) 0xbb, 0x1d, 0x21, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x1d, 0x21
, 0x01, 0x20, 0x78, 0x34, 0x1d, 0x21, 0x00, 0x1d, 0x21, 0x01, 0x1d, 0x21, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x1d, 0x21, 0x01, 0x34
, 0x1d, 0x21, 0x00, 0x0a, 0x1d, 0x21, 0x01, (byte) 0xb2, (byte) (byte) 0xe2, (byte) 0xca, (byte) 0xd4, (byte) 0xc3, (byte) 0xc0, (byte) 0xca, (byte) 0xb3, (byte) 0xb6, (byte) 0xfe, 0x1d, 0x21, 0x00, 0x20, 0x20
, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x1d, 0x21, 0x01, 0x20, 0x78, 0x36, 0x1d, 0x21, 0x00, 0x1d, 0x21
, 0x01, 0x1d, 0x21, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x1d, 0x21, 0x01, 0x36, 0x1d, 0x21, 0x00, 0x0a, 0x1d, 0x21, 0x01, (byte) 0xb2, (byte) (byte) 0xe2
, (byte) 0xca, (byte) 0xd4, (byte) 0xc3, (byte) 0xc0, (byte) 0xca, (byte) 0xb3, (byte) 0xc8, (byte) 0xfd, 0x1d, 0x21, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20
, 0x20, 0x20, 0x1d, 0x21, 0x01, 0x20, 0x78, 0x32, 0x1d, 0x21, 0x00, 0x1d, 0x21, 0x01, 0x1d, 0x21, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20
, 0x1d, 0x21, 0x01, 0x32, 0x1d, 0x21, 0x00, 0x0a, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x20, 0x32, (byte) 0xba
, (byte) 0xc5, (byte) 0xc0, (byte) 0xba, (byte) 0xd7, (byte) 0xd3, 0x20, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x1d, 0x21, 0x01, (byte) 0xb2
, (byte) (byte) 0xe2, (byte) 0xca, (byte) 0xd4, 0x31, 0x1d, 0x21, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20
, 0x20, 0x20, 0x20, 0x1d, 0x21, 0x01, 0x20, 0x78, 0x31, 0x1d, 0x21, 0x00, 0x1d, 0x21, 0x01, 0x1d, 0x21, 0x00, 0x20, 0x20, 0x20, 0x20
, 0x20, 0x1d, 0x21, 0x01, 0x31, 0x1d, 0x21, 0x00, 0x0a, 0x1d, 0x21, 0x01, (byte) 0xb2, (byte) (byte) 0xe2, (byte) 0xca, (byte) 0xd4, 0x32, 0x1d, 0x21, 0x00, 0x20, 0x20
, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x1d, 0x21, 0x01, 0x20, 0x78, 0x31
, 0x1d, 0x21, 0x00, 0x1d, 0x21, 0x01, 0x1d, 0x21, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x1d, 0x21, 0x01, 0x31, 0x1d, 0x21, 0x00, 0x0a
, 0x1d, 0x21, 0x01, (byte) 0xb2, (byte) (byte) 0xe2, (byte) 0xca, (byte) 0xd4, 0x33, 0x1d, 0x21, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20
, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x1d, 0x21, 0x01, 0x20, 0x78, 0x31, 0x1d, 0x21, 0x00, 0x1d, 0x21, 0x01, 0x1d, 0x21, 0x00
, 0x20, 0x20, 0x20, 0x20, 0x1d, 0x21, 0x01, 0x32, 0x33, 0x1d, 0x21, 0x00, 0x0a, 0x1d, 0x21, 0x01, 0x28, 0x2b, 0x29, (byte) 0xb2, (byte) (byte) 0xe2, (byte) 0xca
, (byte) 0xd4, (byte) 0xd1, (byte) 0xf3, (byte) 0xc6, (byte) 0xf8, (byte) 0xa4, (byte) 0xce, (byte) 0xce, (byte) 0xf7, (byte) 0xca, (byte) 0xbd, (byte) 0xcc, (byte) 0xf0, (byte) 0xb5, (byte) (byte) 0xe3, 0x1d, 0x21, 0x00, 0x20, 0x20, 0x1d, 0x21
, 0x01, 0x20, 0x78, 0x31, 0x1d, 0x21, 0x00, 0x1d, 0x21, 0x01, 0x1d, 0x21, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x1d, 0x21, 0x01, 0x31
, 0x1d, 0x21, 0x00, 0x0a, 0x1d, 0x21, 0x01, 0x28, 0x2b, 0x29, (byte) 0xb2, (byte) (byte) 0xe2, (byte) 0xca, (byte) 0xd4, (byte) 0xcb, (byte) (byte) 0xe1, (byte) 0xc0, (byte) 0xb1, (byte) 0xc4, (byte) 0xbe, (byte) 0xb6, (byte) 0xfa
, 0x1d, 0x21, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x1d, 0x21, 0x01, 0x20, 0x78, 0x31, 0x1d, 0x21, 0x00, 0x1d, 0x21
, 0x01, 0x1d, 0x21, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x1d, 0x21, 0x01, 0x38, 0x1d, 0x21, 0x00, 0x0a, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d
, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x20, 0x33, (byte) 0xba, (byte) 0xc5, (byte) 0xc0, (byte) 0xba, (byte) 0xd7, (byte) 0xd3, 0x20, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d
, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x1d, 0x21, 0x01, (byte) 0xb2, (byte) (byte) 0xe2, (byte) 0xca, (byte) 0xd4, (byte) 0xb2, (byte) 0xcb, (byte) 0xc6, (byte) 0xb7, (byte) 0xc3, (byte) 0xfb, (byte) 0xd7, (byte) 0xd6, (byte) 0xba, (byte) 0xdc
, (byte) 0xb3, (byte) 0xa4, (byte) 0xba, (byte) 0xdc, (byte) 0xb3, (byte) 0xa4, (byte) 0xba, (byte) 0xdc, (byte) 0xb3, (byte) 0xa4, (byte) 0xba, (byte) 0xdc, (byte) 0xb3, (byte) 0xa4, (byte) 0xba, (byte) 0xdc, (byte) 0xb3, (byte) 0xa4, 0x1d, 0x21, 0x00, 0x0a
, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20
, 0x20, 0x1d, 0x21, 0x01, 0x20, 0x78, 0x31, 0x1d, 0x21, 0x00, 0x1d, 0x21, 0x01, 0x1d, 0x21, 0x00, 0x20, 0x20, 0x20, 0x1d, 0x21, 0x01
, 0x33, 0x30, 0x30, 0x1d, 0x21, 0x00, 0x0a, 0x1d, 0x21, 0x01, (byte) 0xb2, (byte) (byte) 0xe2, (byte) 0xca, (byte) 0xd4, 0x1d, 0x21, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20
, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x1d, 0x21, 0x01, 0x20, 0x78, 0x31, 0x1d, 0x21
, 0x00, 0x1d, 0x21, 0x01, 0x1d, 0x21, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x1d, 0x21, 0x01, 0x31, 0x1d, 0x21, 0x00, 0x0a, 0x2d, 0x2d
, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x20, (byte) 0xc6, (byte) (byte) 0xe4, (byte) 0xcb, (byte) 0xfb, (byte) 0xb7, (byte) 0xd1, (byte) 0xd3, (byte) 0xc3, 0x20, 0x2d, 0x2d, 0x2d
, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x1d, 0x21, 0x01, (byte) 0xc5, (byte) (byte) 0xe4, (byte) 0xcb, (byte) 0xcd, (byte) 0xb7, (byte) 0xd1, 0x1d, 0x21, 0x00, 0x20
, 0x20, 0x20, 0x20, 0x20
};
return rv;
}
public static byte[] getKoubeiData() {
byte[] rv = new byte[]{
0x1b, 0x40, 0x1b, 0x61, 0x01, 0x1d, 0x21, 0x11, 0x23, 0x34, (byte) 0xbf, (byte) 0xda, (byte) 0xb1, (byte) 0xae, (byte) 0xcd, (byte) 0xe2,
(byte) 0xc2, (byte) 0xf4, 0x0a, 0x1b, 0x40, 0x1b, 0x61, 0x01, 0x1d, 0x21, 0x11, 0x0a, 0x1b, 0x40, 0x1b, 0x61,
0x01, (byte) 0xb7, (byte) 0xeb, (byte) 0xbc, (byte) 0xc7, (byte) 0xbb, (byte) 0xc6, (byte) 0xec, (byte) 0xcb, (byte) 0xbc, (byte) 0xa6, (byte) 0xc3, (byte) 0xd7, (byte) 0xb7, (byte) 0xb9, 0x0a,
0x1b, 0x40, 0x1b, 0x61, 0x00, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x0a, 0x1b, 0x40, 0x1b, 0x61, 0x00, 0x1d, 0x21, 0x11, 0x31, 0x37,
0x3a, 0x32, 0x30, 0x20, (byte) 0xbe, (byte) 0xa1, (byte) 0xbf, (byte) 0xec, (byte) 0xcb, (byte) 0xcd, (byte) 0xb4, (byte) 0xef, 0x0a, 0x1b, 0x40, 0x1b,
0x61, 0x00, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
0x2d, 0x0a, 0x1b, 0x40, 0x1b, 0x61, 0x00, 0x1d, 0x21, 0x11, 0x31, 0x38, 0x36, 0x31, 0x30, 0x38,
0x35, 0x38, 0x33, 0x33, 0x37, 0x1b, 0x61, 0x00, 0x1d, 0x21, 0x01, (byte) 0xce, (byte) 0xa4, (byte) 0xd0, (byte) 0xa1, (byte) 0xb1,
(byte) 0xa6, 0x0a, 0x1b, 0x40, 0x1b, 0x61, 0x00, 0x1d, 0x21, 0x11, (byte) 0xb4, (byte) 0xb4, (byte) 0xd6, (byte) 0xc7, (byte) 0xcc, (byte) 0xec,
(byte) 0xb5, (byte) 0xd8, (byte) 0xb9, (byte) 0xe3, (byte) 0xb3, (byte) 0xa1, 0x37, (byte) 0xba, (byte) 0xc5, (byte) 0xc2, (byte) 0xa5, 0x28, 0x36, 0x30, 0x35, (byte) 0xca,
(byte) 0xd2, 0x29, 0x0a, 0x1b, 0x40, 0x1b, 0x61, 0x00, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x1b, 0x40, 0x1b, 0x61, 0x00, 0x1d, 0x21, 0x01,
(byte) 0xcf, (byte) 0xc2, (byte) 0xb5, (byte) 0xa5, (byte) 0xa3, (byte) 0xba, 0x31, 0x36, 0x3a, 0x33, 0x35, 0x0a, 0x1b, 0x40, 0x1b, 0x61,
0x00, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a, 0x2a,
0x2a, 0x0a, 0x1b, 0x40, 0x1b, 0x61, 0x00, (byte) 0xb2, (byte) 0xcb, (byte) 0xc6, (byte) 0xb7, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x1b, 0x61, 0x00, (byte) 0xca, (byte) 0xfd, (byte) 0xc1, (byte) 0xbf, 0x1b, 0x61, 0x00, 0x20,
0x20, (byte) 0xb5, (byte) 0xa5, (byte) 0xbc, (byte) 0xdb, 0x1b, 0x61, 0x00, 0x20, 0x20, (byte) 0xbd, (byte) 0xf0, (byte) 0xb6, (byte) 0xee, 0x0a, 0x1b,
0x40, 0x1b, 0x61, 0x00, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
0x2d, 0x2d, 0x2d, 0x0a, 0x1b, 0x40, 0x1b, 0x61, 0x00, (byte) 0xbb, (byte) 0xc6, (byte) 0xec, (byte) 0xcb, (byte) 0xce, (byte) 0xe5, (byte) 0xbb,
(byte) 0xa8, (byte) 0xc8, (byte) 0xe2, (byte) 0xb7, (byte) 0xb9, (byte) 0xa3, (byte) 0xa8, (byte) 0xb4, (byte) 0xf3, (byte) 0xa3, (byte) 0xa9, 0x28, (byte) 0xb2, (byte) 0xbb, (byte) 0xc0, (byte) 0xb1,
0x29, 0x0a, 0x1b, 0x40, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x1b, 0x61, 0x00, 0x20, 0x31, 0x20, 0x20, 0x1b, 0x61, 0x00, 0x20, 0x20, 0x20, 0x20,
0x32, 0x35, 0x1b, 0x61, 0x00, 0x20, 0x20, 0x20, 0x20, 0x32, 0x35, 0x0a, 0x1b, 0x40, 0x1b, 0x61,
0x00, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
0x0a, 0x1b, 0x40, 0x1b, 0x61, 0x00, (byte) 0xc5, (byte) 0xe4, (byte) 0xcb, (byte) 0xcd, (byte) 0xb7, (byte) 0xd1, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x1b, 0x61, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x32, 0x0a, 0x1b, 0x40, 0x1b, 0x61, 0x00, 0x2d, 0x2d, 0x2d,
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d,
0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x0a, 0x1b, 0x40, 0x1b,
0x61, 0x00, 0x1d, 0x21, 0x01, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x20, 0x20, (byte) 0xca, (byte) 0xb5, (byte) 0xb8, (byte) 0xb6, (byte) 0xbd, (byte) 0xf0, (byte) 0xb6, (byte) 0xee, (byte) 0xa3, (byte) 0xba, (byte) 0xa3,
(byte) 0xa4, 0x32, 0x37, 0x0a, 0x1b, 0x40, 0x0a, 0x1b, 0x40, 0x0a, 0x1b, 0x40, 0x1b, 0x61, 0x01, 0x1d,
0x21, 0x11, (byte) 0xbf, (byte) 0xda, (byte) 0xb1, (byte) 0xae, (byte) 0xcd, (byte) 0xe2, (byte) 0xc2, (byte) 0xf4, 0x0a, 0x1b, 0x40, 0x0a, 0x1b, 0x40,
0x1d, 0x56, 0x42, 0x0a, 0x0a
};
return rv;
}
//基本覆盖热敏小票打印中所有epson指令的操作
public static byte[] customData() {
byte[] rv = new byte[]{
(byte) 0xB4, (byte) 0xF2, (byte) 0xD3, (byte) 0xA1, (byte) 0xBB, (byte) 0xFA, (byte) 0xD7, (byte) 0xD4, (byte) 0xBC, (byte) 0xEC, 0x0A,
//打印机自检
0x1F, 0X1B, 0x1F, 0x53,
//初始化打印机
0x1B, 0x40,
//分割线---
0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x0A,
(byte) 0xB8, (byte) 0xC4, (byte) 0xB1, (byte) 0xE4, (byte) 0xD7, (byte) 0xD6, (byte) 0xBC, (byte) 0xE4, (byte) 0xBE, (byte) 0xE0, 0x0A,
0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x0A,
//设置字符右间距
0x30, 0x2E, 0x30, 0x3A, (byte) 0xB2, (byte) 0xE2, (byte) 0xCA, (byte) 0xD4, (byte) 0xB2, (byte) 0xE2, (byte) 0xCA, (byte) 0xD4, (byte) 0xB2, (byte) 0xE2, (byte) 0xCA, (byte) 0xD4, 0x0A,
0x30, 0x2E, 0x35, 0x3A, 0x1B, 0x20, 0x0C, (byte) 0xB2, (byte) 0xE2, (byte) 0xCA, (byte) 0xD4, (byte) 0xB2, (byte) 0xE2, (byte) 0xCA, (byte) 0xD4, (byte) 0xB2, (byte) 0xE2, (byte) 0xCA, (byte) 0xD4, 0x0A,
0x1B, 0x20, 0x00,
0x31, 0x2E, 0x30, 0x3A, 0x1B, 0x20, 0x18, (byte) 0xB2, (byte) 0xE2, (byte) 0xCA, (byte) 0xD4, (byte) 0xB2, (byte) 0xE2, (byte) 0xCA, (byte) 0xD4, (byte) 0xB2, (byte) 0xE2, (byte) 0xCA, (byte) 0xD4, 0x0A,
0x1B, 0x20, 0x00,
0x32, 0x2E, 0x30, 0x3A, 0x1B, 0x20, 0x30, (byte) 0xB2, (byte) 0xE2, (byte) 0xCA, (byte) 0xD4, (byte) 0xB2, (byte) 0xE2, (byte) 0xCA, (byte) 0xD4, (byte) 0xB2, (byte) 0xE2, (byte) 0xCA, (byte) 0xD4, 0x0A,
0x1B, 0x20, 0x00,
//分割线===
0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x0A,
(byte) 0xD7, (byte) 0xD6, (byte) 0xCC, (byte) 0xE5, (byte) 0xD0, (byte) 0xA7, (byte) 0xB9, (byte) 0xFB, (byte) 0xC9, (byte) 0xCC, (byte) 0xC3, (byte) 0xD7, (byte) 0xBF, (byte) 0xC6, (byte) 0xBC, (byte) 0xBC, 0x0A,
0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x0A,
//字体效果 商米科技
//设置加粗、倍高、倍宽、下划线、反白
0x1B, 0x21, 0x08, (byte) 0xBC, (byte) 0xD3, (byte) 0xB4, (byte) 0xD6, (byte) 0xC9, (byte) 0xCC, (byte) 0xC3, (byte) 0xD7, (byte) 0xBF, (byte) 0xC6, (byte) 0xBC, (byte) 0xBC, (byte) 0xC9, (byte) 0xCC, (byte) 0xC3, (byte) 0xD7, (byte) 0xBF, (byte) 0xC6, (byte) 0xBC, (byte) 0xBC, 0x0A,
0x1B, 0x21, 0x00,
0x1B, 0x45, 0x01, (byte) 0xBC, (byte) 0xD3, (byte) 0xB4, (byte) 0xD6, (byte) 0xC9, (byte) 0xCC, (byte) 0xC3, (byte) 0xD7, (byte) 0xBF, (byte) 0xC6, (byte) 0xBC, (byte) 0xBC, (byte) 0xC9, (byte) 0xCC, (byte) 0xC3, (byte) 0xD7, (byte) 0xBF, (byte) 0xC6, (byte) 0xBC, (byte) 0xBC, 0x0A,
0x1B, 0x45, 0x00,
0x1B, 0x21, 0x10, (byte) 0xB1, (byte) 0xB6, (byte) 0xB8, (byte) 0xDF, (byte) 0xC9, (byte) 0xCC, (byte) 0xC3, (byte) 0xD7, (byte) 0xBF, (byte) 0xC6, (byte) 0xBC, (byte) 0xBC, (byte) 0xC9, (byte) 0xCC, (byte) 0xC3, (byte) 0xD7, (byte) 0xBF, (byte) 0xC6, (byte) 0xBC, (byte) 0xBC, 0x0A,
0x1B, 0x21, 0x20, (byte) 0xB1, (byte) 0xB6, (byte) 0xBF, (byte) 0xED, (byte) 0xC9, (byte) 0xCC, (byte) 0xC3, (byte) 0xD7, (byte) 0xBF, (byte) 0xC6, (byte) 0xBC, (byte) 0xBC, (byte) 0xC9, (byte) 0xCC, (byte) 0xC3, (byte) 0xD7, (byte) 0xBF, (byte) 0xC6, (byte) 0xBC, (byte) 0xBC, 0x0A,
0x1D, 0x21, 0x11, (byte) 0xC9, (byte) 0xCC, (byte) 0xC3, (byte) 0xD7, (byte) 0xBF, (byte) 0xC6, (byte) 0xBC, (byte) 0xBC,
0x1D, 0x21, 0x22, (byte) 0xC9, (byte) 0xCC, (byte) 0xC3, (byte) 0xD7, (byte) 0xBF, (byte) 0xC6, (byte) 0xBC, (byte) 0xBC, 0x0A,
0x1D, 0x21, 0x00,
0x1B, 0x21, (byte) 0x80, (byte) 0xCF, (byte) 0xC2, (byte) 0xBB, (byte) 0xAE, (byte) 0xCF, (byte) 0xDF, (byte) 0xC9, (byte) 0xCC, (byte) 0xC3, (byte) 0xD7, (byte) 0xBF, (byte) 0xC6, (byte) 0xBC, (byte) 0xBC, (byte) 0xC9, (byte) 0xCC, (byte) 0xC3, (byte) 0xD7, (byte) 0xBF, (byte) 0xC6, (byte) 0xBC, (byte) 0xBC, 0x0A,
0x1B, 0x21, 0x00,
0x1B, 0x2D, 0x01, (byte) 0xCF, (byte) 0xC2, (byte) 0xBB, (byte) 0xAE, (byte) 0xCF, (byte) 0xDF, (byte) 0xC9, (byte) 0xCC, (byte) 0xC3, (byte) 0xD7, (byte) 0xBF, (byte) 0xC6, (byte) 0xBC, (byte) 0xBC, (byte) 0xC9, (byte) 0xCC, (byte) 0xC3, (byte) 0xD7, (byte) 0xBF, (byte) 0xC6, (byte) 0xBC, (byte) 0xBC, 0x0A,
0x1B, 0x2D, 0x00,
0x1D, 0x42, 0x01, 0x1B, 0x21, 0x08, (byte) 0xB7, (byte) 0xB4, (byte) 0xB0, (byte) 0xD7, (byte) 0xC9, (byte) 0xCC, (byte) 0xC3, (byte) 0xD7, (byte) 0xBF, (byte) 0xC6, (byte) 0xBC, (byte) 0xBC, (byte) 0xC9, (byte) 0xCC, (byte) 0xC3, (byte) 0xD7, (byte) 0xBF, (byte) 0xC6, (byte) 0xBC, (byte) 0xBC, 0x0A,
0x1D, 0x42, 0x00, 0x1B, 0x21, 0x00,
//分割线***
0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x0A,
(byte) 0xC5, (byte) 0xC5, (byte) 0xB0, (byte) 0xE6, (byte) 0xCE, (byte) 0xBB, (byte) 0xD6, (byte) 0xC3, 0x0A,
0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x0A,
//排版位置
//设置绝对位置和设置相对位置
(byte) 0xD5, (byte) 0xE2, (byte) 0xBE, (byte) 0xE4, (byte) 0xBB, (byte) 0xB0, (byte) 0xB4, (byte) 0xD3, (byte) 0xD0, (byte) 0xD0, (byte) 0xCA, (byte) 0xD7, (byte) 0xBF, (byte) 0xAA, (byte) 0xCA, (byte) 0xBC, 0x0A,
(byte) 0xBE, (byte) 0xF8, (byte) 0xB6, (byte) 0xD4, (byte) 0xCE, (byte) 0xBB, (byte) 0xD6, (byte) 0xC3, 0x1B, 0x24, (byte) 0xC0, 0x00, (byte) 0xC6, (byte) 0xAB, (byte) 0xD2, (byte) 0xC6, 0x38, (byte) 0xB8, (byte) 0xF6, (byte) 0xD7, (byte) 0xD6, 0x0A,
(byte) 0xCF, (byte) 0xE0, (byte) 0xB6, (byte) 0xD4, (byte) 0xCE, (byte) 0xBB, (byte) 0xD6, (byte) 0xC3, 0x1B, 0x5C, 0x30, 0x00, (byte) 0xC6, (byte) 0xAB, (byte) 0xD2, (byte) 0xC6, 0x32, (byte) 0xB8, (byte) 0xF6, (byte) 0xD7, (byte) 0xD6, 0x0A,
//设置对齐方式
(byte) 0xBE, (byte) 0xD3, (byte) 0xD7, (byte) 0xF3, 0x0A,
0x1B, 0x61, 0x01, (byte) 0xBE, (byte) 0xD3, (byte) 0xD6, (byte) 0xD0, 0x0A,
0x1B, 0x61, 0x02, (byte) 0xBE, (byte) 0xD3, (byte) 0xD3, (byte) 0xD2, 0x0A,
0x1B, 0x61, 0x00,
//设置左边距
0x1D, 0x4C, 0x30, 0x00,
(byte) 0xC9, (byte) 0xE8, (byte) 0xD6, (byte) 0xC3, (byte) 0xD7, (byte) 0xF3, (byte) 0xB1, (byte) 0xDF, (byte) 0xBE, (byte) 0xE0, 0x34, 0x38, (byte) 0xCF, (byte) 0xF1, (byte) 0xCB, (byte) 0xD8, 0x0A,
//设置打印区域宽度
0x1D, 0x57, (byte) 0xF0, 0x00,
(byte) 0xB8, (byte) 0xC4, (byte) 0xB1, (byte) 0xE4, (byte) 0xBF, (byte) 0xC9, (byte) 0xB4, (byte) 0xF2, (byte) 0xD3, (byte) 0xA1, (byte) 0xC7, (byte) 0xF8, (byte) 0xD3, (byte) 0xF2, (byte) 0xCE, (byte) 0xAA, 0x32, 0x34, 0x30, (byte) 0xCF, (byte) 0xF1, (byte) 0xCB, (byte) 0xD8, 0x0A,
//设置左边距
0x1D, 0x4C, 0x60, 0x00,
(byte) 0xC9, (byte) 0xE8, (byte) 0xD6, (byte) 0xC3, (byte) 0xD7, (byte) 0xF3, (byte) 0xB1, (byte) 0xDF, (byte) 0xBE, (byte) 0xE0, 0x39, 0x36, (byte) 0xCF, (byte) 0xF1, (byte) 0xCB, (byte) 0xD8, 0x0A,
//设置打印区域宽度
0x1D, 0x57, (byte) 0x78, 0x00,
(byte) 0xB8, (byte) 0xC4, (byte) 0xB1, (byte) 0xE4, (byte) 0xBF, (byte) 0xC9, (byte) 0xB4, (byte) 0xF2, (byte) 0xD3, (byte) 0xA1, (byte) 0xC7, (byte) 0xF8, (byte) 0xD3, (byte) 0xF2, (byte) 0xCE, (byte) 0xAA, 0x31, 0x32, 0x30, (byte) 0xCF, (byte) 0xF1, (byte) 0xCB, (byte) 0xD8, 0x0A,
0x1D, 0x4C, 0x00, 0x00,
0x1D, 0x57, (byte) 0x80, 0x01,
//水平制表符-跳格
(byte) 0xC4, (byte) 0xAC, 0x09, (byte) 0xC8, (byte) 0xCF, 0x09, (byte) 0xCC, (byte) 0xF8, 0x09, (byte) 0xB8, (byte) 0xF1, 0x09, 0x0A,
0x1B, 0x44, 0x01, 0x02, 0x04, 0x08, 0x0A, 0x00,
(byte) 0xD7, (byte) 0xD4, 0x09, (byte) 0xB6, (byte) 0xA8, 0x09, (byte) 0xD2, (byte) 0xE5, 0x09, (byte) 0xCC, (byte) 0xF8, 0x09, (byte) 0xB8, (byte) 0xF1, 0x09, 0x0A,
//设置行高
0x1B, 0x33, 0x60, (byte) 0xC9, (byte) 0xE8, (byte) 0xD6, (byte) 0xC3, (byte) 0xD0, (byte) 0xD0, (byte) 0xB8, (byte) 0xDF, 0x3A, 0x39, 0x36, (byte) 0xB5, (byte) 0xE3, (byte) 0xD0, (byte) 0xD0, 0x0A,
0x1B, 0x33, 0x40, (byte) 0xC9, (byte) 0xE8, (byte) 0xD6, (byte) 0xC3, (byte) 0xD0, (byte) 0xD0, (byte) 0xB8, (byte) 0xDF, 0x3A, 0x36, 0x34, (byte) 0xB5, (byte) 0xE3, (byte) 0xD0, (byte) 0xD0, 0x0A,
0x1B, 0x33, 0x00, (byte) 0xC9, (byte) 0xE8, (byte) 0xD6, (byte) 0xC3, (byte) 0xD0, (byte) 0xD0, (byte) 0xB8, (byte) 0xDF, 0x3A, 0x30, (byte) 0xB5, (byte) 0xE3, (byte) 0xD0, (byte) 0xD0, 0x0A,
0x1B, 0x32, (byte) 0xC4, (byte) 0xAC, (byte) 0xC8, (byte) 0xCF, (byte) 0xD0, (byte) 0xD0, (byte) 0xB8, (byte) 0xDF, 0x0A,
//分割线---
0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x0A,
(byte) 0xD6, (byte) 0xAE, (byte) 0xBA, (byte) 0xF3, (byte) 0xBD, (byte) 0xAB, (byte) 0xD7, (byte) 0xDF, (byte) 0xD6, (byte) 0xBD, 0x0A,
0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x0A,
//打印并走纸
0x1B, 0x4A, 0x40, (byte) 0xD7, (byte) 0xDF, (byte) 0xD6, (byte) 0xBD, 0x36, 0x34, (byte) 0xB5, (byte) 0xE3, (byte) 0xD0, (byte) 0xD0, 0x0A,
0x1B, 0x4A, 0x60, (byte) 0xD7, (byte) 0xDF, (byte) 0xD6, (byte) 0xBD, 0x39, 0x36, (byte) 0xB5, (byte) 0xE3, (byte) 0xD0, (byte) 0xD0, 0x0A,
0x1B, 0x64, 0x0A, (byte) 0xD7, (byte) 0xDF, (byte) 0xD6, (byte) 0xBD, 0x31, 0x30, (byte) 0xD0, (byte) 0xD0, 0x0A,
0x1B, 0x64, 0x01, (byte) 0xD7, (byte) 0xDF, (byte) 0xD6, (byte) 0xBD, 0x31, (byte) 0xD0, (byte) 0xD0, 0x0A,
//分割线===
0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x0A,
(byte) 0xB4, (byte) 0xF2, (byte) 0xD3, (byte) 0xA1, (byte) 0xCC, (byte) 0xF5, (byte) 0xC2, (byte) 0xEB, 0x0A,
0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x0A,
//打印条码
0x1D, 0x48, 0x02,
//upca
0x1B, 0x61, 0x00, 0x1D, 0x68, 0x20, 0x1D, 0x77, 0x02,
0x1D, 0x6B, 0x41, 0x0c, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0x31, 0x32, 0x0A,
0x1D, 0x6B, 0x00, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0x31, 0x32, 0x00, 0x0A,
//upce
0x1B, 0x61, 0x01, 0x1D, 0x68, 0x40, 0x1D, 0x77, 0x04,
0x1D, 0x6B, 0x42, 0x08, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x0A,
0x1D, 0x6B, 0x01, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x00, 0x0A,
//ean13
0x1B, 0x61, 0x02, 0x1D, 0x68, 0x60, 0x1D, 0x77, 0x02,
0x1D, 0x6B, 0x43, 0x0D, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0x31, 0x32, 0x0A,
0x1D, 0x6B, 0x02, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0x31, 0x32, 0x00, 0x0A,
//ean8
0x1B, 0x61, 0x00, 0x1D, 0x68, (byte) 0x80, 0x1D, 0x77, 0x05,
0x1D, 0x6B, 0x44, 0x08, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x0A,
0x1D, 0x6B, 0x03, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x00, 0x0A,
//code39
0x1B, 0x61, 0x01, 0x1D, 0x68, (byte) 0xA0, 0x1D, 0x77, 0x02,
0x1D, 0x6B, 0x45, 0x0A, 0x33, 0x36, 0x39, 0x53, 0x55, 0x4E, 0x4D, 0x49, 0x25, 0x24, 0x0A,
0x1D, 0x6B, 0x04, 0x33, 0x36, 0x39, 0x53, 0x55, 0x4E, 0x4D, 0x49, 0x25, 0x24, 0x00, 0x0A,
//itf
0x1B, 0x61, 0x02, 0x1D, 0x68, (byte) 0xC0, 0x1D, 0x77, 0x03,
0x1D, 0x6B, 0x46, 0x0C, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0x31, 0x0A,
0x1D, 0x6B, 0x05, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0x31, 0x00, 0x0A,
//codebar
0x1B, 0x61, 0x00, 0x1D, 0x68, (byte) 0xE0, 0x1D, 0x77, 0x03,
0x1D, 0x6B, 0x47, 0x0A, 0x41, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x41, 0x0A,
//0x1D, 0x6B, 0x06, 0x41, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x41, 0x00, 0x0A,
//code93
0x1B, 0x61, 0x01, 0x1D, 0x68, (byte) 0xFF, 0x1D, 0x77, 0x02,
0x1D, 0x6B, 0x48, 0x0C, 0x53, 0x55, 0x4E, 0x4D, 0x49, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x0A,
//code128
0x1B, 0x61, 0x00, 0x1D, 0x68, (byte) 0xB0, 0x1D, 0x77, 0x02,
0x1D, 0x6B, 0x49, 0x0A, 0x7B, 0x41, 0x53, 0x55, 0x4E, 0x4D, 0x49, 0x30, 0x31, 0x32, 0x0A,
0x1D, 0x6B, 0x49, 0x0C, 0x7B, 0x42, 0x53, 0x55, 0x4E, 0x4D, 0x49, 0x73, 0x75, 0x6E, 0x6D, 0x69, 0x0A,
0x1D, 0x6B, 0x49, 0x0B, 0x7B, 0x43, 0x01, 0xc, 0x17, 0x22, 0x2d, 0x38, 0x4e, 0x59, 0x5a, 0x0A,
//分割线***
0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x0A,
(byte) 0xB4, (byte) 0xF2, (byte) 0xD3, (byte) 0xA1, (byte) 0xB6, (byte) 0xFE, (byte) 0xCE, (byte) 0xAC, (byte) 0xC2, (byte) 0xEB, 0x0A,
0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x0A,
//打印二维码
0x1B, 0x61, 0x01,
0x1D, 0x28, 0x6B, 0x03, 0x00, 0x31, 0x43, 0x09,
0x1D, 0x28, 0x6B, 0x03, 0x00, 0x31, 0x45, 0x32,
0x1D, 0x28, 0x6B, 0x0B, 0x00, 0x31, 0x50, 0x30, (byte) 0xC9, (byte) 0xCC, (byte) 0xC3, (byte) 0xD7, (byte) 0xBF, (byte) 0xC6, (byte) 0xBC, (byte) 0xBC,
0x1D, 0x28, 0x6B, 0x03, 0x00, 0x31, 0x51, 0x30, 0x0A,
0x1B, 0x61, 0x00,
//分割线--- (之后将实现打印光栅位图的方法,再次之前使用1b 61 01 居中)
0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x0A,
(byte) 0xB4, (byte) 0xF2, (byte) 0xD3, (byte) 0xA1, (byte) 0xB9, (byte) 0xE2, (byte) 0xD5, (byte) 0xA4, (byte) 0xCD, (byte) 0xBC, (byte) 0xCF, (byte) 0xF1, 0x0A,
0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x0A,
0x1B, 0x61, 0x01,
};
return rv;
}
//部分字符打印的分割线标志
public static byte[] wordData() {
byte rv[] = new byte[]{
//分割线===
0x1B, 0x61, 0x00,
0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x0A,
(byte) 0xD7, (byte) 0xD6, (byte) 0xB7, (byte) 0xFB, (byte) 0xBC, (byte) 0xAF, (byte) 0xC9, (byte) 0xE8, (byte) 0xD6, (byte) 0xC3, 0x0A,
0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x0A,
0x1C, 0x26, 0x1C, 0x43, 0x00,
};
return rv;
}
}
package com.miya.print.utils;
import android.graphics.Bitmap;
import java.io.ByteArrayOutputStream;
//常用指令封装
public class ESCUtil {
public static final byte ESC = 0x1B;// Escape
public static final byte FS = 0x1C;// Text delimiter
public static final byte GS = 0x1D;// Group separator
public static final byte DLE = 0x10;// data link escape
public static final byte EOT = 0x04;// End of transmission
public static final byte ENQ = 0x05;// Enquiry character
public static final byte SP = 0x20;// Spaces
public static final byte HT = 0x09;// Horizontal list
public static final byte LF = 0x0A;//Print and wrap (horizontal orientation)
public static final byte CR = 0x0D;// Home key
public static final byte FF = 0x0C;// Carriage control (print and return to the standard mode (in page mode))
public static final byte CAN = 0x18;// Canceled (cancel print data in page mode)
//初始化打印机
public static byte[] init_printer() {
byte[] result = new byte[2];
result[0] = ESC;
result[1] = 0x40;
return result;
}
//打印浓度指令
public static byte[] setPrinterDarkness(int value){
byte[] result = new byte[9];
result[0] = GS;
result[1] = 40;
result[2] = 69;
result[3] = 4;
result[4] = 0;
result[5] = 5;
result[6] = 5;
result[7] = (byte) (value >> 8);
result[8] = (byte) value;
return result;
}
/**
* 打印单个二维码 sunmi自定义指令
* @param code: 二维码数据
* @param modulesize: 二维码块大小(单位:点, 取值 1 至 16 )
* @param errorlevel: 二维码纠错等级(0 至 3)
* 0 -- 纠错级别L ( 7%)
* 1 -- 纠错级别M (15%)
* 2 -- 纠错级别Q (25%)
* 3 -- 纠错级别H (30%)
*/
public static byte[] getPrintQRCode(String code, int modulesize, int errorlevel){
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
try{
buffer.write(setQRCodeSize(modulesize));
buffer.write(setQRCodeErrorLevel(errorlevel));
buffer.write(getQCodeBytes(code));
buffer.write(getBytesForPrintQRCode(true));
}catch(Exception e){
e.printStackTrace();
}
return buffer.toByteArray();
}
/**
* 横向两个二维码 sunmi自定义指令
* @param code1: 二维码数据
* @param code2: 二维码数据
* @param modulesize: 二维码块大小(单位:点, 取值 1 至 16 )
* @param errorlevel: 二维码纠错等级(0 至 3)
* 0 -- 纠错级别L ( 7%)
* 1 -- 纠错级别M (15%)
* 2 -- 纠错级别Q (25%)
* 3 -- 纠错级别H (30%)
*/
public static byte[] getPrintDoubleQRCode(String code1, String code2, int modulesize, int errorlevel){
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
try{
buffer.write(setQRCodeSize(modulesize));
buffer.write(setQRCodeErrorLevel(errorlevel));
buffer.write(getQCodeBytes(code1));
buffer.write(getBytesForPrintQRCode(false));
buffer.write(getQCodeBytes(code2));
//加入横向间隔
buffer.write(new byte[]{0x1B, 0x5C, 0x18, 0x00});
buffer.write(getBytesForPrintQRCode(true));
}catch(Exception e){
e.printStackTrace();
}
return buffer.toByteArray();
}
/**
* 光栅打印二维码
*/
public static byte[] getPrintQRCode2(String data, int size){
byte[] bytes1 = new byte[4];
bytes1[0] = GS;
bytes1[1] = 0x76;
bytes1[2] = 0x30;
bytes1[3] = 0x00;
byte[] bytes2 = BytesUtil.getZXingQRCode(data, size);
return BytesUtil.byteMerger(bytes1, bytes2);
}
/**
* 打印一维条形码
*/
public static byte[] getPrintBarCode(String data, int symbology, int height, int width, int textposition){
if(symbology < 0 || symbology > 10){
return new byte[]{LF};
}
if(width < 2 || width > 6){
width = 2;
}
if(textposition <0 || textposition > 3){
textposition = 0;
}
if(height < 1 || height>255){
height = 162;
}
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
try{
buffer.write(new byte[]{0x1D,0x66,0x01,0x1D,0x48,(byte)textposition,
0x1D,0x77,(byte)width,0x1D,0x68,(byte)height,0x0A});
byte[] barcode;
if(symbology == 10){
barcode = BytesUtil.getBytesFromDecString(data);
}else{
barcode = data.getBytes("GB18030");
}
if(symbology > 7){
buffer.write(new byte[]{0x1D,0x6B,0x49,(byte)(barcode.length+2),0x7B, (byte) (0x41+symbology-8)});
}else{
buffer.write(new byte[]{0x1D,0x6B,(byte)(symbology + 0x41),(byte)barcode.length});
}
buffer.write(barcode);
}catch(Exception e){
e.printStackTrace();
}
return buffer.toByteArray();
}
//光栅位图打印
public static byte[] printBitmap(Bitmap bitmap){
byte[] bytes1 = new byte[4];
bytes1[0] = GS;
bytes1[1] = 0x76;
bytes1[2] = 0x30;
bytes1[3] = 0x00;
byte[] bytes2 = BytesUtil.getBytesFromBitMap(bitmap);
return BytesUtil.byteMerger(bytes1, bytes2);
}
//光栅位图打印 设置mode
public static byte[] printBitmap(Bitmap bitmap, int mode){
byte[] bytes1 = new byte[4];
bytes1[0] = GS;
bytes1[1] = 0x76;
bytes1[2] = 0x30;
bytes1[3] = (byte) mode;
byte[] bytes2 = BytesUtil.getBytesFromBitMap(bitmap);
return BytesUtil.byteMerger(bytes1, bytes2);
}
//光栅位图打印
public static byte[] printBitmap(byte[] bytes){
byte[] bytes1 = new byte[4];
bytes1[0] = GS;
bytes1[1] = 0x76;
bytes1[2] = 0x30;
bytes1[3] = 0x00;
return BytesUtil.byteMerger(bytes1, bytes);
}
/*
* 选择位图指令 设置mode
* 需要设置1B 33 00将行间距设为0
*/
public static byte[] selectBitmap(Bitmap bitmap, int mode){
return BytesUtil.byteMerger(BytesUtil.byteMerger(new byte[]{0x1B, 0x33, 0x00}, BytesUtil.getBytesFromBitMap(bitmap, mode)), new byte[]{0x0A, 0x1B, 0x32});
}
/**
* 跳指定行数
*/
public static byte[] nextLine(int lineNum) {
byte[] result = new byte[lineNum];
for (int i = 0; i < lineNum; i++) {
result[i] = LF;
}
return result;
}
// ------------------------underline-----------------------------
//设置下划线1点
public static byte[] underlineWithOneDotWidthOn() {
byte[] result = new byte[3];
result[0] = ESC;
result[1] = 45;
result[2] = 1;
return result;
}
//设置下划线2点
public static byte[] underlineWithTwoDotWidthOn() {
byte[] result = new byte[3];
result[0] = ESC;
result[1] = 45;
result[2] = 2;
return result;
}
//取消下划线
public static byte[] underlineOff() {
byte[] result = new byte[3];
result[0] = ESC;
result[1] = 45;
result[2] = 0;
return result;
}
// ------------------------bold-----------------------------
/**
* 字体加粗
*/
public static byte[] boldOn() {
byte[] result = new byte[3];
result[0] = ESC;
result[1] = 69;
result[2] = 0xF;
return result;
}
/**
* 取消字体加粗
*/
public static byte[] boldOff() {
byte[] result = new byte[3];
result[0] = ESC;
result[1] = 69;
result[2] = 0;
return result;
}
// ------------------------character-----------------------------
/*
*单字节模式开启
*/
public static byte[] singleByte(){
byte[] result = new byte[2];
result[0] = FS;
result[1] = 0x2E;
return result;
}
/*
*单字节模式关闭
*/
public static byte[] singleByteOff(){
byte[] result = new byte[2];
result[0] = FS;
result[1] = 0x26;
return result;
}
/**
* 设置单字节字符集
*/
public static byte[] setCodeSystemSingle(byte charset){
byte[] result = new byte[3];
result[0] = ESC;
result[1] = 0x74;
result[2] = charset;
return result;
}
/**
* 设置多字节字符集
*/
public static byte[] setCodeSystem(byte charset){
byte[] result = new byte[3];
result[0] = FS;
result[1] = 0x43;
result[2] = charset;
return result;
}
// ------------------------Align-----------------------------
/**
* 居左
*/
public static byte[] alignLeft() {
byte[] result = new byte[3];
result[0] = ESC;
result[1] = 97;
result[2] = 0;
return result;
}
/**
* 居中对齐
*/
public static byte[] alignCenter() {
byte[] result = new byte[3];
result[0] = ESC;
result[1] = 97;
result[2] = 1;
return result;
}
/**
* 居右
*/
public static byte[] alignRight() {
byte[] result = new byte[3];
result[0] = ESC;
result[1] = 97;
result[2] = 2;
return result;
}
//切刀
public static byte[] cutter() {
byte[] data = new byte[]{0x1d, 0x56, 0x01};
return data;
}
//走纸到黑标
public static byte[] gogogo(){
byte[] data = new byte[]{0x1C, 0x28, 0x4C, 0x02, 0x00, 0x42, 0x31};
return data;
}
////////////////////////////////////////////////////////////////////////////////////
////////////////////////// private /////////////////////////
////////////////////////////////////////////////////////////////////////////////////
private static byte[] setQRCodeSize(int modulesize){
//二维码块大小设置指令
byte[] dtmp = new byte[8];
dtmp[0] = GS;
dtmp[1] = 0x28;
dtmp[2] = 0x6B;
dtmp[3] = 0x03;
dtmp[4] = 0x00;
dtmp[5] = 0x31;
dtmp[6] = 0x43;
dtmp[7] = (byte)modulesize;
return dtmp;
}
private static byte[] setQRCodeErrorLevel(int errorlevel){
//二维码纠错等级设置指令
byte[] dtmp = new byte[8];
dtmp[0] = GS;
dtmp[1] = 0x28;
dtmp[2] = 0x6B;
dtmp[3] = 0x03;
dtmp[4] = 0x00;
dtmp[5] = 0x31;
dtmp[6] = 0x45;
dtmp[7] = (byte)(48+errorlevel);
return dtmp;
}
private static byte[] getBytesForPrintQRCode(boolean single){
//打印已存入数据的二维码
byte[] dtmp;
if(single){ //同一行只打印一个QRCode, 后面加换行
dtmp = new byte[9];
dtmp[8] = 0x0A;
}else{
dtmp = new byte[8];
}
dtmp[0] = 0x1D;
dtmp[1] = 0x28;
dtmp[2] = 0x6B;
dtmp[3] = 0x03;
dtmp[4] = 0x00;
dtmp[5] = 0x31;
dtmp[6] = 0x51;
dtmp[7] = 0x30;
return dtmp;
}
private static byte[] getQCodeBytes(String code) {
//二维码存入指令
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
try {
byte[] d = code.getBytes("GB18030");
int len = d.length + 3;
if (len > 7092) len = 7092;
buffer.write((byte) 0x1D);
buffer.write((byte) 0x28);
buffer.write((byte) 0x6B);
buffer.write((byte) len);
buffer.write((byte) (len >> 8));
buffer.write((byte) 0x31);
buffer.write((byte) 0x50);
buffer.write((byte) 0x30);
for (int i = 0; i < d.length && i < len; i++) {
buffer.write(d[i]);
}
} catch (Exception e) {
e.printStackTrace();
}
return buffer.toByteArray();
}
}
\ No newline at end of file
...@@ -2,9 +2,6 @@ package com.miya.print.utils; ...@@ -2,9 +2,6 @@ package com.miya.print.utils;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.text.TextUtils; import android.text.TextUtils;
import com.blankj.utilcode.util.RegexUtils;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset; import java.nio.charset.Charset;
......
...@@ -2,16 +2,13 @@ package com.miya.print.utils; ...@@ -2,16 +2,13 @@ package com.miya.print.utils;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.text.TextUtils; import android.text.TextUtils;
import com.blankj.utilcode.util.RegexUtils;
import java.nio.charset.Charset; import java.nio.charset.Charset;
/** /**
* Created by fengyu on 2018/2/23. * Created by fengyu on 2018/2/23.
*/ */
public class Page88MmPrintUtils { public class Page80MmPrintUtils {
/** /**
* 打印纸一行最大的字节 * 打印纸一行最大的字节
......
package com.miya.print.utils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public final class RegexUtils {
private RegexUtils() {
throw new UnsupportedOperationException("u can't instantiate me...");
}
/**
* Return whether input matches the regex.
*
* @param regex The regex.
* @param input The input.
* @return {@code true}: yes<br>{@code false}: no
*/
public static boolean isMatch(final String regex, final CharSequence input) {
return input != null && input.length() > 0 && Pattern.matches(regex, input);
}
/**
* Return the list of input matches the regex.
*
* @param regex The regex.
* @param input The input.
* @return the list of input matches the regex
*/
public static List<String> getMatches(final String regex, final CharSequence input) {
if (input == null) return Collections.emptyList();
List<String> matches = new ArrayList<>();
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(input);
while (matcher.find()) {
matches.add(matcher.group());
}
return matches;
}
/**
* Splits input around matches of the regex.
*
* @param input The input.
* @param regex The regex.
* @return the array of strings computed by splitting input around matches of regex
*/
public static String[] getSplits(final String input, final String regex) {
if (input == null) return new String[0];
return input.split(regex);
}
/**
* Replace the first subsequence of the input sequence that matches the
* regex with the given replacement string.
*
* @param input The input.
* @param regex The regex.
* @param replacement The replacement string.
* @return the string constructed by replacing the first matching
* subsequence by the replacement string, substituting captured
* subsequences as needed
*/
public static String getReplaceFirst(final String input,
final String regex,
final String replacement) {
if (input == null) return "";
return Pattern.compile(regex).matcher(input).replaceFirst(replacement);
}
/**
* Replace every subsequence of the input sequence that matches the
* pattern with the given replacement string.
*
* @param input The input.
* @param regex The regex.
* @param replacement The replacement string.
* @return the string constructed by replacing each matching subsequence
* by the replacement string, substituting captured subsequences
* as needed
*/
public static String getReplaceAll(final String input,
final String regex,
final String replacement) {
if (input == null) return "";
return Pattern.compile(regex).matcher(input).replaceAll(replacement);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment