我一直在尝试在 android 中做一个 POS 应用程序,我在连接到该应用程序的蓝牙打印机上打印收据。我可以使用设备随附的 HOINSDK 打印“大”、“小”和 QR 码,并且可以对齐“左”和“中心”,但无法将其与“右”对齐。任何帮助表示赞赏。
以下是各个事物的代码:
//For Large Text
cmd[0] = 27;
cmd[1] = 97;
cmd[2] &= 0xEF;
mService.write(cmd);
mService.sendMessage("" + large_txt.getText().toString(), "GBK");
//For Small Text
cmd[0] = 0x1b;
cmd[1] = 0x21;
cmd[2] &= 0xEF;
mService.write(cmd);
mService.sendMessage("" + small_txt.getText().toString(), "GBK");
//For Center Alignment small text
cmd[0] = 27;
cmd[1] = 97;
cmd[2] |= 1;
mService.write(cmd);
cmd[0] = 27;
cmd[1] = 97;
cmd[2] = 1;
mService.write(cmd);
mService.sendMessage("" + center_txt.getText().toString(), "GBK");
//For centre alignment Large Text
cmd[1] = 97;
cmd[2] |= 1;
mService.write(cmd);
cmd[0] = 0x1b;
cmd[1] = 0x21;
cmd[2] = 0x10;
mService.write(cmd);
mService.sendMessage("" + center_txt.getText().toString(), "GBK");
//For Left alignment
cmd[0] = 27;
cmd[1] = 97;
cmd[2] |= 1;
mService.write(cmd);
cmd[0] = 27;
cmd[1] = 97;
cmd[2] = 0;
mService.write(cmd);
mService.sendMessage("" + left_txt.getText().toString(), "GBK");
如果有人可以帮助我使用正确的对齐代码,那将会很有帮助。