java如何在打印机中打印选项卡
我必须用Java通过热敏打印机打印收据。 对于格式,我可以理解如何在手册的基础上打印align center,如下所示:
中心手册:
[Name] Select justification
[Format] ASCII ESC a n
Hex 1B 61 n
Decimal 27 97 n
[Range] 0 ≤ n ≤ 2, 48 ≤ n ≤ 50
[Description] Aligns all the data in one line to the specified position.
n selects the type of justification as follows:
n Justification
0, 48 Left justification
1, 49 Centering
2, 50 Right justification
所以下面的代码是有效的: 中心代码:
private void printAlignCenter(){
byte[] cmd = new byte[3];
cmd[0] = 0x1B;
cmd[1] = 0x61;
cmd[2] = 0x01;
wfComm.sndByte(cmd);
}
现在,选项卡设置和选项卡手册: 选项卡手册:
[Name] Set horizontal tab positions
[Format] ASCII ESC D n1...nk NUL
Hex 1B 44 n1...nk 00
Decimal 27 68 n1...nk 0
[Range] 1 ≤ n ≤ 255
0 ≤ k ≤ 32
[Description] Sets horizontal tab positions.
▪ n specifies the column number (counted from the beginning of the
line) for setting a horizontal tab position.
▪ k indicates the total number of horizontal tab positions to be set.
[Name] Horizontal tab
[Format] ASCII HT
Hex 09
Decimal 10
[Description] Moves the print position to the next horizontal tab position
[Notes] ▪ This command is ignored unless the next horizontal tab position
has been set.
但下面的代码不起作用: 选项卡代码:
private void printTabEnable(){
byte[] cmd = new byte[3];
cmd[0] = 0x1B;
cmd[1] = 0x44;
cmd[2] = 0x28;
// cmd[3] = 0x08;//08//10
// cmd[4] = 0x12;//12//20
wfComm.sndByte(cmd);
}
private void printTab(){
byte[] cmd = new byte[1];
cmd[0] = 0x09;
wfComm.sndByte(cmd);
}
# 1 楼答案
我认为,您缺少结束制表符设置的
NUL
字节: