public static final byte ESC = 27;//Exchange public static final byte FS = 28;//text delimiter public static final byte GS = 29;/ /Group separator public static final byte DLE = 16;//data Connection Exchange code public static final byte EOT = 4;//transfer End public static final B Yte ENQ = 5;//Inquiry character public static final byte SP = 32;//space public static final byte HT = 9;//Landscape list public static Final byte LF = 10;//print and line wrap (horizontal positioning) public static final byte CR = 13;//return key public static final byte FF = 12;//paper control (hit Print and return to standard mode (in page mode) public static final byte CAN = 24;//void (cancel print data in page mode)//------------------------printer initialization----------- ------------------/** * Printer Initialization * *@return */public static byte[] Init_printer () {byte[] result = new BYTE[2];
Result[0] = ESC;
RESULT[1] = 64;
return result; }//------------------------line break-----------------------------/** * Line * *@param-linenum to change a few lines. */public static byte[] nextline (int linenum) {byte[] result = new Byte[linenum];
for (int i = 0; i < linenum; i++) {result[i] = LF;
} return result; }//------------------------underline-----------------------------/** * Draw an underscore (1 dots wide) */public static by
Te[] Underlinewithonedotwidthon () {byte[] result = new BYTE[3];
Result[0] = ESC;
RESULT[1] = 45;
RESULT[2] = 1;
return result; }/** * Draw underline (2 dots wide) * */public static byte[] Underlinewithtwodotwidthon () {byte[] result = new BYTE[3];
Result[0] = ESC;
RESULT[1] = 45;
RESULT[2] = 2;
return result; }/** * un-draw underline */public static byte[] Underlineoff () {byte[] result = new BYTE[3];
Result[0] = ESC;
RESULT[1] = 45;
RESULT[2] = 0;
return result; }//------------------------bold-----------------------------/** * Select bold mode */public static byte[] Boldon () {byte[] result = new BYTE[3];
Result[0] = ESC;
RESULT[1] = 69;
RESULT[2] = 0xF;
return result; }/** * Remove bold mode */public static byte[] Boldoff () {byte[] result = new BYTE[3];
Result[0] = ESC;
RESULT[1] = 69;
RESULT[2] = 0;
return result; }//------------------------align-----------------------------/** * Align Left */public static byte[] AlignLeft () {byte[] result = new BYTE[3];
Result[0] = ESC;
RESULT[1] = 97;
RESULT[2] = 0;
return result; }/** * Center alignment */public static byte[] AlignCenter () {byte[] result = new BYTE[3];
Result[0] = ESC;
RESULT[1] = 97;
RESULT[2] = 1;
return result; }/** * Right alignment */public static byte[] AlignRight () {byte[] result = new BYTE[3];
Result[0] = ESC;
RESULT[1] = 97;
RESULT[2] = 2;
return result; }/** * Move the col column to the right in the horizontal direction */public static byte[] Set_ht_position (byte col) {byte[] result = new BYTE[4];
Result[0] = ESC;
RESULT[1] = 68;
Result[2] = col;
RESULT[3] = 0;
return result; }//------------------------font becomes larger-----------------------------/** * Font size is larger to n times of standard */public static byte[] fontsizesetbig (int num) {byte realsize = 0;
Switch (num) {case 1:realsize = 0;
Break
Case 2:realsize = 17;
Break
Case 3:realsize = 34;
Break
Case 4:realsize = 51;
Break
Case 5:realsize = 68;
Break
Case 6:realsize = 85;
Break
Case 7:realsize = 102;
Break
Case 8:realsize = 119;
Break
} byte[] result = new BYTE[3];
Result[0] = 29;
Result[1] = 33;
RESULT[2] = realsize;
return result; }/** * font is double-width times high */public static byte[] fontsizesetsmall (int num) {byte[] result = new BYTE[3];
Result[0] = ESC;
Result[1] = 33;
return result; }//------------------------paper cut-----------------------------/** * feed and cut all * */public static byte[] Feedpapercutall () {byte[] result = new BYTE[4];
Result[0] = GS;
RESULT[1] = 86;
RESULT[2] = 65;
RESULT[3] = 0;
return result; }/** * Feed and cut (leave a little left) */public static byte[] Feedpapercutpartial () {byte[] result = new BYTE[4];
Result[0] = GS;
RESULT[1] = 86;
RESULT[2] = 66;
RESULT[3] = 0;
return result; }