0

I want to add Hindi character set into my Thermal printer (Gprinter Model:GP-U80030I) using escape sequence (ESC/POS). I read Escape commands from program manual. In what sequence I should send commands to printer. Commands to be used are:

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

I am sending ascii values to printer (ex. ESC - 27, % - 38 etc).

jrbedard
  • 3,662
  • 5
  • 30
  • 34

1 Answers1

3

Start with something like this:

 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);

    }

Don't forget to activate custom fonts with command afterwards:

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

Now, when you send the 'A' character to the printer it will print your custom defined character (black sqare because all the bits are set to 1)..

kometonja
  • 437
  • 4
  • 15
  • I hope this will help me out to print arabic characters, but im afraid that english characters which prints perfectly now will get affected after i set or change the character code. would that affect? – Naz141 Mar 21 '18 at 09:13
  • In this case, character 'A' would be overwritten with another character, yes. You can replace special characters that you won't use for example in 33-64 range. Or you can have function defineArabChars() and resetArabChars() and switch your charsets when needed.. – kometonja Mar 21 '18 at 13:41