2016-11-07 22 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)。

相關問題