Find this one. This will help solve your problem. The ESC / POS command reference contains detailed information about ESC / POS commands, such as standard command syntax and protocol. It is intended for programmers who want to control the printer using ESC / POS commands.
ESC/POS ESC/POS APG . ESC/POS APG .
ESC/POS , ANK , .
, , . , .
. OutPutStream , , Bluetooth, Ethernet Wi-Fi.
public class PrinterConstants {
public static int PORT=9100,TOTAL_CHAR=45,DIV1=10,DIV2=5,DIV3=10,DIV4=10,DIV5=10;
public static String IP="192.168.1.35";
private OutputStream printer;
public static final String UUID="00001101-0000-1000-8000-00805f9b34fb";
public PrinterConstants(OutputStream printer){
this.printer=printer;
}
public void printString(String str) throws IOException {
Log.i("PRINTER_PRE",str);
printer.write(str.getBytes());
printer.write(0xA);
printer.flush();
}
public void storeString(String str) throws IOException {
printer.write(str.getBytes());
printer.flush();
}
public void printStorage() throws IOException {
printer.write(0xA);
printer.flush();
}
public void feed(int feed) throws IOException {
printer.write(0x1B);
printer.write("d".getBytes());
printer.write(feed);printer.flush();
}
public void printAndFeed(String str, int feed) throws IOException {
printer.write(str.getBytes());
printer.write(0x1B);
printer.write("d".getBytes());
printer.write(feed);printer.flush();
}
public void setBold(Boolean bool) throws IOException {
printer.write(0x1B);
printer.write("E".getBytes());
printer.write((int)(bool?1:0));printer.flush();
}
public void setInverse(Boolean bool) throws IOException {
bool=false;
printer.write(0x1D);
printer.write("B".getBytes());
printer.write( (int)(bool?1:0) );printer.flush();
}
public void resetToDefault() throws IOException {
setInverse(false);
setBold(false);
setUnderline(0);
setJustification(0);printer.flush();
}
public void setUnderline(int val) throws IOException {
printer.write(0x1B);
printer.write("-".getBytes());
printer.write(val);printer.flush();
}
public void setJustification(int val) throws IOException {
printer.write(0x1B);
printer.write("a".getBytes());
printer.write(val);
printer.flush();
}
public void setLeftRight(String left,String right) throws IOException {
printer.write(0x1B);
printer.write("a".getBytes());
printer.write(0);
printString(left);
printer.write(0x1B);
printer.write("a".getBytes());
printer.write(2);
printString(right);
printer.flush();
}
public void printBarcode(String code, int type, int h, int w, int font, int pos) throws IOException {
printer.write(0x1D);
printer.write("H".getBytes());
printer.write(pos);
printer.write(0x1D);
printer.write("f".getBytes());
printer.write(font);
printer.write(0x1D);
printer.write("h".getBytes());
printer.write(h);
printer.write(0x1D);
printer.write("w".getBytes());
printer.write(w);
printer.write(0x1D);
printer.write("k".getBytes());
printer.write(type);
printer.write(code.length());
printer.write(code.getBytes());
printer.write(0);
printer.flush();
}
public void beep() throws IOException {
printer.write(0x1B);
printer.write("(A".getBytes());
printer.write(4);
printer.write(0);
printer.write(48);
printer.write(55);
printer.write(3);
printer.write(15);printer.flush();
}
public void setLineSpacing(int spacing) throws IOException {
printer.write(0x1B);
printer.write("3".getBytes());
printer.write(spacing);
}
public void cut() throws IOException {
printer.write(0x1D);
printer.write("V".getBytes());
printer.write(48);
printer.write(0);printer.flush();
}
}
, ESC/POS