Android ESC SDK Manual V1.06
Android ESC SDK Manual V1.06
1
3.12 Set print density.................................. 19
3.13 Set print speed.................................... 19
3.14 Cut paper..............................................20
3.15 Drawer................................................... 21
3.16 Beep buzzer......................................... 21
3.17 Print text............................................... 22
3.18 Print barcode....................................... 24
3.19 Print 2D code....................................... 26
3.20 Print bitmap..........................................27
3.21 Send data to the printer.................... 28
3.22 Read data from the printer................29
3.23 Print PDF417........................................30
3.24 Label location...................................... 35
3.25 Select page mode...............................35
3.26 Set print area in page mode............. 36
3.27 Set print direction in page mode..... 38
3.28 Set print position in page mode...... 39
3.29 Print in page mode............................. 40
3.30 Get NV bitmap list...............................41
3.31 Get NV bitmap memory capacity.... 41
3.32 Get NV bitmap remaining capacity. 42
3.33 Print NV bitmap................................... 43
2
3.34 Delete specified NV bitmap.............. 43
3.35 Delete all NV bitmap...........................44
3.36 Download NV bitmap to the printer 44
3.37 Print Binary file.................................... 45
3.38 Get printer function list...................... 45
3.39 Clear page mode print area data.....48
3.40 Print and return standard mode.......48
3.41 Set the left margin.............................. 48
3.42 Read magnetic card information..... 49
3.43 Exit magnetic card mode.................. 50
3.44 Set mobile unit.................................... 50
3.45 Print rectangle..................................... 51
3.46 Print Line...............................................52
3.47 Image data compression print......... 53
3.48 Get Printer SN..................................... 54
3.49 Get Printer Quantity............................55
Table 1-1........................................................56
3
1. SDK Introduction
1) SDK jar :
In this jar, there are connectors which connect to the printer. Our
2) SO Library :
4
2. Connecting Method
Connect Bluetooth :
Parameter:
context:Context object.
Example:
Print.PortOpen(context,“Bluetooth,”+MAC)
Return:
0: connection success
Disconnect Bluetooth:
Example:
Print.PorClose()
Return:
5
Example:
Print.IsOpened()
Return:
Connect WIFI:
Example:
Print.PortOpen(context,“WiFi,”+IP+”,”+PortNumber)
Return:
0: connection success
Disconnect WiFi:
Example:
Print.PorClose()
Return:
6
True: disconnection success
Example:
Print.IsOpened()
Return:
True: connected
False: unconnected
Connect USB:
Example:
Print.PortOpen(context,usbdevice)
Return:
0:connection success
-1:connection failure
Disconnect USB:
Example:
7
Print.PorClose()
Return:
true:Disconnection success
false:disconnection failure
Example:
Print.IsOpened()
Return:
true:connected
false:unconnected
Example:
Print.PortOpen(“Serial,”+port+”,”+baudrate)
Return:
8
0: connection success
Example:
Print.PorClose()
Return:
Example:
Print.IsOpened()
Return:
true: connected
false: unconnected
9
3.Print Command
Example:
Print.PrintAndLineFeed()
Return:
Example:
Print.PrintAndFeed(distance)
Return:
Example:
10
Print.PrintAndReverseFeed(distance)
Return:
Example:
Print.PrintAndFeedNLine(lines)
Return:
Example:Print.PrintAndReverseFeedNLine(lines)
Return:
11
3.6 Set text line space
Example:
Print.SetDefaultTextLineSpace()
Example:
Print.SetTextLineSpace(byte lineSpace)
Return:
Example:
Print.SelectCharacterFont(byte characterFont)
characterFont:
Return:
12
-1:sending (to printer) failure
Example:
Print.SetCharacterSet(byte characterSet)
Print.LanguageEncode=”gb2312”
Print.SetCharacterSet(0)
Set English:
Print.LanguageEncode=”iso8859-1”
Print.SetCharacterSet(0)
Print.LanguageEncode=”big5”
Print.SetCharacterSet(0)
To set other languages, please refer to Table 1-1 on the last two
pages.
Return:
13
3.9 Set justification
Example:
Print.SetJustification(int justification)
1: center
2:right justifying
Return:
Function:
GetRealTimeStatus(byte realTimeItem)
Parameter:
14
realTimeItem=1
Bit 0/1 Hex Decimal Status
0 0 00 0 Fixed to 0
1 0 02 2 Fixed to 0
2 0 00 0 Fixed to 0
0 00 0 Online
3
1 08 8 Offline
4 1 10 16 Fixed to 0
5 0 00 0 Fixed to 0
realTimeItem=2
Bit 0/1 Hex Decimal Status
0 0 00 0 Fixed to 0
1 0 00 0 Fixed to 0
2 0 00 0 Fixed to 0
3 0 00 0 Fixed to 0
4 0 00 0 Fixed to 0
5 0 00 0 Fixed to 0
15
realTimeItem=3
Bit 0/1 Hex Decimal Status
0 0 00 0 Fixed to 0
1 0 00 0 Fixed to 0
2 0 00 0 Fixed to 0
3 0 00 0 Fixed to 0
4 0 00 0 Fixed to 0
0 00 0 Close cover
5
1 20 0 Open cover
0 00 0 Normal temperature
6
1 40 64 Abnormal temperature
7 0 00 0 Fixed to 0
realTimeItem=4
Bit 0/1 Hex Decimal Status
0 0 00 0 Fixed to 0
1 0 00 0 Fixed to 0
4 0 00 0 Fixed to 0
0 00 0 has paper
5,6
1 60 96 no paper
7 0 00 0 Fixed to 0
length of 1.
Query paper:
Bit OFF/N Hex Decimal Status
O
OFF 00 0 Sufficient paper
0,1
NO 03 3 Paper will be exhausted
4 OFF 00 0 Fixed
5,6 _ _ _ Reserved
7 OFF 00 0 Fixed
17
Check the cash box:
Bit OFF/N Hex Decimal Status
O
OFF 00 0 Cash box pin 3 signal low
0
NO 01 1 Cash box pin 3 signal high
1-3 _ _ _ Reserved
4 OFF 00 0 Fixed
5,6 _ _ _ Reserved
7 OFF 00 0 Fixed
Example:
byte statusData = Print.GetTransmitStatus(1);
Example:
Print.Initialize()
Return:
18
3.12 Set print density
Function:
Print.SetPrintDensity(byte density)
density:Printer density
Return:
Function:
Print.SetPrintSpeed(byte speed)
speed:Printer speed
Return:
19
3.14 Cut paper
Function:
Print.CutPaper(int cutMode)
cutMode: default is 1
Function:
cutMode: default is 1
note:
The paper travel distance is calculated from outside the print area.
Return:
20
3.15 Drawer
Function:
Print.OpenCashdrawer(int openMode)
Return:
Function:
Return:
21
3.17 Print text
1.Function:
Print.PrintText(String data)
Example:
Print.PrintText(“TEXT\n”)
2.Function:
1:center
2:right alignment
attribute: style.
Print.PrintText(“TEXT\n”,0,14,0)
Return:
23
3.18 Print barcode
Function:
Function:
Parameter:
24
bcData: data of bar code
HRIPosition:
0: left justifying
1: center
2: right justifying
Example:
Print.PrintBarCode(73,"{BS/N:{C\014\042\070\116{A3",1,50,2,0);//
Print code128:
S/N:123456783
Return:
25
≠-1:sending (to printer) success
Function:
PrintQRCode(String bcData)
Parameter:
Function:
justification)
Parameter:
0: left justifying
1: center
26
2: right justifying
Example:
Print.PrintQRCode(“data of 2D code”,6,48,0)
Return:
Function:
Parameter:
0:Black-White.
1:Shake.
2:gater.
Example:
Print.PrintBitmap(bmp,1,0)
Return:
27
3.21 Send data to the printer
Function:
Parameter:
Example:
Return:
28
3.22 Read data from the printer
Function:
Parameter:
Example:
Print.ReadData(2000)
Return:
29
3.23 Print PDF417
Function:
byte dataColumns,
byte dataRows,
byte moduleWidth,
byte rowHeight,
byte errorMode,
byte errorLevel,
byte options)
Parameter:
0-30).
30
48: level mode
Level mode:
31
7
32
Ratio mode: [Data code ×n ×0.1=(A)](decimal part round-off)
Error Correction
Code
400 8
33
1: select compacted PDF417
Return:
Example:
Print.PrintPDF417(“123456”,(byte)0,(byte)0,(byte)3,(byte)3,(byte)49,
(byte)1,(byte)0)
34
3.24 Label location
Function:
int GotoNextLabel()
Note:
continuous paper.
Example:
Print.GotoNextLabel()
Return:
Example:
Print.SelectPageMode()
Under page mode you can set the position which you want to
print.
35
Print.SelectPageMode()
Print.SetPageModePrintArea(0,0,200,200)
Print.SetPageModePrintDirection(0)
//Set position of x, y
Print.SetPageModeAbsolutePosition(0,0)
Print.PrintQRCode("abcdef",4,48,1)
Print.PrintDataInPageMode()
Return:
height)
Note: The printer should support page mode function. And it can
Parameter:
36
vertical: y-coordinate of start point
Example:
Print.SelectPageMode()
Print.SetPageModePrintArea(0,0,200,200)
Print.SetPageModePrintDirection(0)
//Set position of x, y
Print.SetPageModeAbsolutePosition(0,0)
Print.PrintQRCode("abcdef",4,48,1)
Print.PrintDataInPageMode()
Return:
37
3.27 Set print direction in page mode
Note: The printer should support page mode function. And it can
Parameter:
0:0°
1:90°
2:180°
3:270°
Example:
Print.SelectPageMode()
Print.SetPageModePrintArea(0,0,200,200)
Print.SetPageModePrintDirection(0)
//Set position of x, y
Print.SetPageModeAbsolutePosition(0,0)
Print.PrintQRCode("abcdef",4,48,1)
38
Print.PrintDataInPageMode()
Return:
Note: The printer should support page mode function. And it can
Parameter:
xPosition:X-coordinate
yPosition:Y-coordinate
Example:
Print.SelectPageMode()
Print.SetPageModePrintArea(0,0,200,200)
Print.SetPageModePrintDirection(0)
//Set position of x, y
Print.SetPageModeAbsolutePosition(0,0)
39
Print.PrintQRCode("abcdef",4,48,1)
Print.PrintDataInPageMode()
Return:
int PrintDataInPageMode()
Note: The printer should support page mode function. And it can
Example:
Print.SelectPageMode()
Print.SetPageModePrintArea(0,0,200,200)
Print.SetPageModePrintDirection(0)
//Set position of x, y
Print.SetPageModeAbsolutePosition(0,0)
Print.PrintQRCode("abcdef",4,48,1)
40
//Print
Print.PrintDataInPageMode()
Return:
effect.
Parameter:
Example:
Print.RefreshImageList(lbImageIndex)
Return:
effect.
41
Parameter:
Example:
iSpace=new int[1];
Print.QueryNVStoreCapacity(iSpace);
Return:
int QueryNVStoreRemainingCapacity(int[]
storeRemainingCapacity)
effect.
Parameter:
Example:
storeRemainingCapacity=new int[1];
Print.QueryNVStoreRemainingCapacity(storeRemainingCapacity);
Return:
42
3.33 Print NV bitmap
effect.
Parameter:
Example:
Print.PrintNVImage(imageNo,0);
Return:
effect.
Parameter:
Example:
Print.DeleteSpecifiedNVImage(sImageIndex);
Return:
43
≠-1: sending (to printer) success
int DeleteAllNVImage()
effect.
Example:
Print.DeleteAllNVImage();
Return:
effect.
Parameter:
44
Example:
Print.DefineNVImage(sArrFile,handler);
Return:
Parameter:
Example:
Print.PrintBinaryFile(strPRNFile);
Return:
Parameter:
ModelPropertyKeyBeep:function code
MODEL_PROPERTY_KEY_BEEP:beeper
45
MODEL_PROPERTY_KEY_CUT:cut paper
MODEL_PROPERTY_KEY_DRAWER:drawer
MODEL_PROPERTY_KEY_BARCODE:bar code
MODEL_PROPERTY_KEY_PAGEMODE:page mode
MODEL_PROPERTY_KEY_GET_REMAINING_POWE :
power
MODEL_PROPERTY_CONNECT_TYPE:connection type
MODEL_PROPERTY_KEY_PRINT_RECEIPT:receipt
Value[0]==0 support.
Otherwise nonsupport
(Bar code)
Example:
46
Print.CapturePrinterFunction(ModelPropertyKeyBeep,propType,V
alue,DataLen);
Return:
47
3.39 Clear page mode print area data
int ClearPageModePrintAreaData()
Example:
Print.ClearPageModePrintAreaData();
Return:
int PrintAndReturnStandardMode()
Example:
Print.PrintAndReturnStandardMode();
Return:
Parameter:
Print.PrintAndReturnStandardMode();
48
Return:
cardReader,int outTime)
Parameter:
Print.setTrackCardReaderMode(track,new
Print.CardReader() {
@Override
49
public void Succeed(final byte[] data) {
}
@Override
public void Failure(final int error) {
}
},30*1000);
boolean CancelTrackCardReaderMode()
Example:
Print.CancelTrackCardReaderMode();
Return:
true:success。
false:failure。
50
unit:25.4/ x mm,
25.4/ y mm。
range:(0-255)。
Return:
> 0: sending (to printer) success
-2:Parameter error
Example:
Print.setPrintResolution(203,203);
51
lineWidth:Line width.
Return:
≠-1: sending (to printer) success
Example:
Print.PrintPageRectangle(0,0,100,100,2);
52
-1: sending (to printer) failure
Example:
Print.PrintPageLine(0,0,100,100,2);
Example:
Print.PrintBitmapLZO(bitmap,0);
53
3.48 Get Printer SN
String getPrintSN()
Note:
This interface is only supported by some printers
Parameter :
Null
Return:
≠-1: sending (to printer) success
Example:
Print.getPrintSN();
54
3.49 Get Printer Quantity
String getPrinterQuantity()
Note:
This interface is only supported by some printers
Parameter :
Null
Return:
-1: sending (to printer) failure
-2:printer nonsupport
Other:Printer Quantity
Example:
Print.getPrinterQuantity();
55
Table 1-1
Name Character Set Code page
Default 0 gb2312
Chinese Simplified 0 gb2312
Chinese Traditional 0 big5
PC437(USA) 0 iso8859-1
KataKana 1 Shift_JIS
PC850(Multilingual) 2 iso8859-3
PC860(Portuguese) 3 iso8859-6
PC863(Canadian-French) 4 iso8859-1
PC865(Nordic) 5 iso8859-1
PC857(Turkish) 13 IBM857
PC737(Greek) 14 iso8859-7
ISO8859-7(Greek) 15 iso8859-7
WCP1252 16 iso8859-1
PC866(Cyrillic #2) 17 iso8859-5
PC852(Latin 2) 18 iso8859-2
PC858(Euro) 19 iso8859-15
KU42 20 ISO8859-11
TIS11(Thai) 21 ISO8859-11
TIS18(Thai) 26 ISO8859-11
PC720 32 iso8859-6
WPC775 33 iso8859-1
PC855(Cyrillic) 33 iso8859-5
PC862(Hebrew) 36 iso8859-8
PC864(Arabic) 37 iso8859-6
ISO8859-2(Latin2) 39 iso8859-2
ISO8859-15(Latin9) 40 iso8859-15
WPC1250 45 iso8859-2
WPC1251(Cyrillic) 46 iso8859-5
WPC1253 47 iso8859-7
WPC1254 48 iso8859-3
WPC1255 49 iso8859-8
WPC1256 50 Windows-1256
WPC1257 51 iso8859-1
WPC1258 52 bg2312
MIK(Cyrillic/Bulgarian) 54 iso8859-15
CP755 55 iso8859-5
Iran 56 iso8859-6
Iran II 57 iso8859-6
Latvian 58 iso8859-4
56
ISO-8859-1(West Europe) 59 iso8859-1
ISO-8859-3(Latin 3) 60 iso8859-3
ISO-8859-4(Baltic) 61 iso8859-4
ISO-8859-5(Cyrillic) 62 iso8859-5
ISO-8859-6(Arabic) 63 iso8859-6
ISO-8859-8(Hebrew) 64 iso8859-8
ISO-8859-9(Turkish) 65 iso8859-9
PC856 66 iso8859-8
ABICOIM 67 iso8859-15
57