2016-11-07 24 views
0

我想使用转义序列(ESC/POS)将印地语字符集添加到我的热敏打印机(Gprinter型号:GP-U80030I)中。我从程序手册中读取Escape命令。我应该以什么顺序向打印机发送命令。 命令要使用的有:如何使用Escape序列在热敏打印机中添加用户定义的字符集?

ESC % n 
ESC & y c1 c2 [x1 d1...d(y X x1)]...[xk d1...d(y X xk)] 
ESC ? n 

我送ASCII值到打印机(例如ESC - 27% - 38等)。

回答

1
像这样的东西

开始:

private void defineChars() { 
     int[] cmd = new int[5 + 37] ; // already set to 0 
     cmd[0] = 0x1b; // ESC 
     cmd[1] = 0x26; // & 
     cmd[2] = 0x03; // y - height 
     cmd[3] = 'A'; // starting char to define, c1, 'A' .. 
     cmd[4] = 'A'; // c2, ending character, in this case we define only one 
     cmd[5] = 12; // x1, dots in horizontal direction 

     int shift = 6; 

     // fill the matrix as you wish.. 
     // 'A' -> black square 
     for (int i = 0; i < 36; i++) { 
      cmd[i + shift] = 0xff; 
     } 
     sendCommand(cmd); 

    } 

不要忘记激活自定义字体与命令算账:

private void setCustomChars(boolean set) { 
     //select user defined chars 
     sendCommand(0x1B, 0x25, (set) ? 1 : 0); 
    } 

现在,当您发送“A”字符打印机它将打印您的自定义字符(黑色sqare,因为所有位都设置为1)。

相关问题