I am working on an application for an Android device that will have a built in line printer. I have to interact with this printer and use it to print the details on receipt and then with cutter cut that receipt automatically. I have seen some ESC commands in it, but I don't know how to execute these ESC commands.
I have three main issues regarding the Casio Device Printer :
1.I have used the printing code for Build in printer, but after printing the cutter is not activated
BuildinEx840 ex840 = new BuildinEx840();
int response = ex840.open();
System.out.println("ex840 open:" + response);
byte[] set = {
'N', 'A', 'R', 'E', 'S', 'H', 'S', 'H', 'A', 'R', 'M', 'A', (byte) 0x0d, (byte) 0x0a
};
try {
ex840.write(set);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
response = ex840.getEndStatus();
System.out.println("getEndStatus:" + response);
response = ex840.initCutter();
ex840.close();
System.out.println("initCutter:" + response);
} catch (Exception e) {
e.printStackTrace();
}
2. I don't know how to send ESC commands to the Printer in android
There are number of commands like below
ESC FF DataPrint,
[code] <1B>H<OC>H,
[Function] Print all the data in the print area collectively.
How can we execute these ESC commands in android by programming ??
3.I don't know how to print the receipt in the required format
There are some ESC commands are available for providing margins from left and right and some other commands. So how can I print the data in some formate and can change the size of the text as well as some other settings of the text to be printed.
Any help is appreciated.