0% found this document useful (0 votes)
86 views57 pages

Android ESC SDK Manual V1.06

The document provides an overview and instructions for using the Android ESC SDK for printers. It describes 4 connection methods (Bluetooth, WiFi, USB, signal interface), lists over 50 print commands covering text, barcodes, images and more. It also includes tables defining status codes and supported character encodings.

Uploaded by

hec_tor_coutinho
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
86 views57 pages

Android ESC SDK Manual V1.06

The document provides an overview and instructions for using the Android ESC SDK for printers. It describes 4 connection methods (Bluetooth, WiFi, USB, signal interface), lists over 50 print commands covering text, barcodes, images and more. It also includes tables defining status codes and supported character encodings.

Uploaded by

hec_tor_coutinho
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 57

Android ESC SDK Manual

Android ESC SDK Manual............................................ 1


1. SDK Introduction............................................... 4
2. Connecting Method...........................................5
2.1 Bluetooth Connection.............................5
2.2 WIFI Connection...................................... 6
2.3 USB Connection...................................... 7
2.4 Signal Interface Connection.................. 8
3.Print Command................................................. 10
3.1 Paper feed.............................................. 10
3.2 Paper feed after printing...................... 10
3.3 Reverse feed after printing.................. 10
3.4 Print and feed n line..............................11
3.5 Print and reverse feed n line............... 11
3.6 Set text line space................................ 12
3.7 Select character font............................ 12
3.8 Set language.......................................... 13
3.9 Set justification...................................... 14
3.10 Get printer status................................ 14
3.11 Initializing printer................................. 18

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

SDK connectors include Bluetooth, USB, WIFI and signal interface.

It also includes the connector of print commands, such as printing

text, bar code, image, and so on.

2) SO Library :

4
2. Connecting Method

2.1 Bluetooth Connection

Connect Bluetooth :

int PortOpen(Context context,String portSetting)

Parameter:

context:Context object.

portSetting: “Bluetooth,”+Bluetooth address

Example:

Print.PortOpen(context,“Bluetooth,”+MAC)

MAC: Bluetooth address of printer

Return:

0: connection success

-1: connection failure

Disconnect Bluetooth:

Example:

Print.PorClose()

Return:

True: disconnection success

False: disconnection failure

Whether Bluetooth is connected:

5
Example:

Print.IsOpened()

Return:

True: Bluetooth connected

False: Bluetooth unconnected

2.2 WIFI Connection

Connect WIFI:

int PortOpen(Context context,String portSetting)

Example:

Print.PortOpen(context,“WiFi,”+IP+”,”+PortNumber)

IP: IP address of printer

PortNumber: port Defaul: 9100

Return:

0: connection success

-1: connection failure

Disconnect WiFi:

Example:

Print.PorClose()

Return:

6
True: disconnection success

False: disconnection failure

Whether WiFi is connected:

Example:

Print.IsOpened()

Return:

True: connected

False: unconnected

2.3 USB Connection

Connect USB:

int PortOpen(Context context,UsbDevice usbdevice)

Example:

Print.PortOpen(context,usbdevice)

usbdevice: UsbDevice object

Return:

0:connection success

-1:connection failure

Disconnect USB:

Example:

7
Print.PorClose()

Return:

true:Disconnection success

false:disconnection failure

Whether USB is connected:

Example:

Print.IsOpened()

Return:

true:connected

false:unconnected

2.4 Signal Interface Connection

Connect signal interface:

int PortOpen(Context context,String portSetting)

Example:

Print.PortOpen(“Serial,”+port+”,”+baudrate)

port: node of signal interface (differ from models) e.g./dev/ttyS1

baudrate: baud rate e.g.9600

Return:

8
0: connection success

-1: connection failure

Disconnect signal interface:

Example:

Print.PorClose()

Return:

true: disconnection success

false: disconnection failure

Whether signal interface is connected:

Example:

Print.IsOpened()

Return:

true: connected

false: unconnected

9
3.Print Command

3.1 Paper feed

Example:

Print.PrintAndLineFeed()

Return:

≠-1: sending (to printer) success

-1: sending (to printer) failure

3.2 Paper feed after printing

Example:

Print.PrintAndFeed(distance)

distance:paper feeding length(Unit: distance*y model unit mm)

Return:

≠-1: sending (to printer) success

-1: sending (to printer) failure

3.3 Reverse feed after printing

Example:

10
Print.PrintAndReverseFeed(distance)

distance: reverse feed length (distance*y model unit mm)

Return:

≠-1:sending (to printer) success

-1:sending (to printer) failure

3.4 Print and feed n line

Example:

Print.PrintAndFeedNLine(lines)

lines:N X (current line spacing)

Return:

≠-1:sending (to printer) success

-1:sending (to printer) failure

3.5 Print and reverse feed n line

Example:Print.PrintAndReverseFeedNLine(lines)

lines:N X (current line spacing)

Return:

≠-1:sending (to printer) success

-1:sending (to printer) failure

11
3.6 Set text line space

Example:

Print.SetDefaultTextLineSpace()

Note: Set default text line (3.75mm)

Example:

Print.SetTextLineSpace(byte lineSpace)

lineSpace: line spacing (lineSpace*y model unit mm)

Return:

≠-1:sending (to printer) success

-1:sending (to printer) failure

3.7 Select character font

Example:

Print.SelectCharacterFont(byte characterFont)

characterFont:

0:FontA big font

1:FontB small font

Return:

≠-1:sending (to printer) success

12
-1:sending (to printer) failure

3.8 Set language

Example:

Print.SetCharacterSet(byte characterSet)

Set simple Chinese:

Print.LanguageEncode=”gb2312”

Print.SetCharacterSet(0)

Set English:

Print.LanguageEncode=”iso8859-1”

Print.SetCharacterSet(0)

Set traditional Chinese:

Print.LanguageEncode=”big5”

Print.SetCharacterSet(0)

To set other languages, please refer to Table 1-1 on the last two

pages.

Return:

≠-1:sending (to printer) success

-1:sending (to printer) failure

13
3.9 Set justification

Example:

Print.SetJustification(int justification)

justification: 0: left justifying

1: center

2:right justifying

Return:

≠-1:sending (to printer) success

-1:sending (to printer) failure

3.10 Get printer status

Function:

GetRealTimeStatus(byte realTimeItem)
Parameter:

1: Transfer the printer status.

2: Transfer printer status.

3: Transfer printer status.

4: Transfer paper status.

Returns: statusData: The status returned (as shown in the

following table) length of 1.

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

0 00 0 Printer status is normal


6
1 40 64 Printer status is abnormal
7 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

6 0 00 0 Printer status is normal


1 40 64 Printer status is abnormal
7
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

0 00 0 Paper bin without paper


2,3
1 0C 12 Paper bin has paper

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

statusData.length==0 Acquisition failed


Example:
byte statusData =
16
Print.GetRealTimeStatus((byte)4);
(2)function:(Suitable for serial port reading)
Print.GetTransmitStatus(int transmitItem)
transmitItem: 1:Get paper status.
2:Get cash box status.
return:
statusData: The status returned (as shown in the following table)

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

OFF 00 0 Paper exists


2,3
NO 0C 12 Paper not exist

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

3.11 Initializing printer

Example:

Print.Initialize()

Restore the printer to the start-up status.

Return:

≠-1:sending (to printer) success

-1:sending (to printer) failure

18
3.12 Set print density

Function:

Print.SetPrintDensity(byte density)

density:Printer density

Return:

≠-1:sending (to printer) success

-1:sending (to printer) failure

3.13 Set print speed

Function:

Print.SetPrintSpeed(byte speed)

speed:Printer speed

Return:

≠-1:sending (to printer) success

-1:sending (to printer) failure

19
3.14 Cut paper

Function:

Print.CutPaper(int cutMode)

cutMode: default is 1

Feed paper and then cut paper

Function:

Print.CutPaper(int cutMode,int distance)

cutMode: default is 1

distance: feeding distance (distance*y model unit mm)

note:

The paper travel distance is calculated from outside the print area.

Return:

≠-1:sending (to printer) success

-1:sending (to printer) failure

20
3.15 Drawer

Function:

Print.OpenCashdrawer(int openMode)

openMode: 0:Open No.1 drawer

1:Open No.2 drawer

2:Open two drawers

Return:

≠-1:sending (to printer) success

-1:sending (to printer) failure

3.16 Beep buzzer

Function:

Print.BeepBuzzer(byte times,byte t1,byte t2)

times: times of beep

t1: time of beep(t1× 100ms)。

t2: time of stop(t2× 100ms)。

Return:

≠-1:sending (to printer) success

-1:sending (to printer) failure

21
3.17 Print text

1.Function:

Print.PrintText(String data)

data: text content

Example:

Print.PrintText(“TEXT\n”)

2.Function:

PrintText(String data,int alignment,int attribute,int textSize)

data: text content

alignment: alignment method 0:left alignment

1:center

2:right alignment

attribute: style.

0 : Large font,no bold, no underline, no


highlight.
1:small font,no bold, no underline, no highlight.
2:Large font,bold, no underline, no highlight.
3:small font,bold, no underline, no highlight.
4:Large font,no bold, underline, no highlight.
5:small font,no bold, underline, no highlight.
6:Large font,bold, underline, no highlight.
22
7:small font,bold, underline, no highlight.
8:Large font,no bold, no underline, highlight.
9:small font,no bold, no underline, highlight.
10:Large font,bold, no underline, highlight.
11:small font,bold, no underline, highlight.
12:Large font,no bold, underline, highlight.
13:small font,no bold, underline, highlight.
14:Large font,bold, underline, highlight.
15:small font,bold, underline, highlight.

textSize: Font magnification.

[Range]:textSize=(0 To 7, 16 To 23, 32 To 39, 48


To 55, 64 To 71, 80 To 87, 96 To 103, 112 To 119;)
font hight multiple =textSize%8;
font width multiple=textSize/8;
Example:

Print.PrintText(“TEXT\n”,0,14,0)

Return:

≠-1:sending (to printer) success

-1:sending (to printer) failure

23
3.18 Print barcode

Function:

PrintBarCode(int bcType,String bcData)

bcType:type of bar code

n indicates number of bytes of bar code data

d specifies bar code data

bcData: data of bar code

Function:

PrintBarCode(int bcType,String bcData,int width,int height,int

HRIPosition, int justification)

Parameter:

bcType: type of bar code

24
bcData: data of bar code

width:bar code width Range:(1-6)


Narrow Bar Code Wide Bar Code
Width (mm)
(mm) (mm)
1 0.125 0.125 0.250
2 0.25 0.25 0.625
3 0.375 0.375 2.303
4 0.5 0.5 1.250
5 0.625 0.625 1.625
6 0.750 0.750 2
height:height of bar code range:1-255。

HRIPosition:

Select the HRI print position when printing bar code.


n Print Position
0,48 No print
1,49 Above the bar code
2,50 Below the bar code
3,51 Both above and below the bar code

justification: justification method

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

-1:sending (to printer) failure

3.19 Print 2D code

Function:

PrintQRCode(String bcData)

Parameter:

bcData: data of 2D code

Function:

PrintQRCode(String bcData,int sizeOfModule,int errorLevel,int

justification)

Parameter:

bcData: data of 2D code

sizeOfModule: size of 2D code range 1-16;

errorLevel: level of error correction


N Function Refer: recoverable character
ratio
48 Select error correction L 7%
49 Select error correction M 15%
50 Select error correction Q 25%
51 Select error correction R 30%

justification: justification method

0: left justifying

1: center

26
2: right justifying

Example:

Print.PrintQRCode(“data of 2D code”,6,48,0)

Return:

≠-1:sending (to printer) success

-1:sending (to printer) failure

3.20 Print bitmap

Function:

PrintBitmap(Bitmap bmp,int halftoneType,int luminance)

Parameter:

bmp: image object

halftoneType: algorithm type of image

0:Black-White.

1:Shake.

2:gater.

luminance:brightness(range: -100 To100)

Example:

Print.PrintBitmap(bmp,1,0)

Return:

≠-1: sending (to printer) success

-1: sending (to printer) failure

27
3.21 Send data to the printer

Function:

int WriteData(byte[] bData)

Parameter:

bData:the data sent to the printer

Example:

Print.WriteData(“123abc\n”.getBytes("GB2312"))//Send the data of

‘123abc’ to the printer.

Return:

≠-1: sending (to printer) success

-1: sending (to printer) failure

28
3.22 Read data from the printer

Function:

byte[] ReadData(int time)

Parameter:

Time: time of timeout (Unit: millisecond)

Example:

Print.ReadData(2000)

//The data read from the printer.

Return:

The data returned from the printer, length = 0 no data returned

from the printer.

29
3.23 Print PDF417

Function:

int PrintPDF417(String bcData,

byte dataColumns,

byte dataRows,

byte moduleWidth,

byte rowHeight,

byte errorMode,

byte errorLevel,

byte options)

Parameter:

bcData: the content of data

dataColumns: sets the number of columns in data print area (range:

0-30).

0: automatic setting. The number of print columns is set according

to the print range.

dataRows: sets the umber of rows of PDF417 (range: 0, 3-90).

0: automatic setting. The number of print rows is set according to

the print range.

moduleWidth: sets the width of the module (range: 2-8).

rowHeight: sets the height of the module =n*width (range: 2-n-8).

errorMode: error correction mode

30
48: level mode

49: ratio mode

errorLevel: two modes (n)

Level mode:

Error Correction Number of


n Function
PDF417 Code

48 Select error correction level 2

49 Select error correction level 4

50 Select error correction level 8

51 Select error correction level 16

52 Select error correction level 32

53 Select error correction level 64

54 Select error correction level 128

55 Select error correction level 256

31
7

56 Select error correction level 512

32
Ratio mode: [Data code ×n ×0.1=(A)](decimal part round-off)

Error Correction

A Function Number of PDF417

Code

0~3 Select error correction level 4

4~10 Select error correction level 8

11~20 Select error correction level 16

21~45 Select error correction level 32

46~100 Select error correction level 64

101~200 Select error correction level 128

201~400 Select error correction level 256

Above Select error correction level 512

400 8

Options: select the options

0: select standard PDF417

33
1: select compacted PDF417

Return:

≠-1: sending (to printer) success

=-1: sending (to printer) failure

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:

This command is only for label location, not applicable for

continuous paper.

Example:

Print.GotoNextLabel()

//Locate to the gap of label paper.

Return:

≠-1: sending (to printer) success

-1: sending (to printer) failure

3.25 Select page mode

Example:

Print.SelectPageMode()

Note: The printer should support page mode function.

Under page mode you can set the position which you want to

print.

//Enter page mode

35
Print.SelectPageMode()

//Set print area

Print.SetPageModePrintArea(0,0,200,200)

//Set print direction

Print.SetPageModePrintDirection(0)

//Set position of x, y

Print.SetPageModeAbsolutePosition(0,0)

//Print 2D code (can also print text and bar code)

Print.PrintQRCode("abcdef",4,48,1)

//Print

Print.PrintDataInPageMode()

Return:

≠-1:sending (to printer) success

-1:sending (to printer) failure

3.26 Set print area in page mode

int SetPageModePrintArea(int horizontal,int vertical,int width,int

height)

Note: The printer should support page mode function. And it can

take effect only when entering the page mode.

Parameter:

horizontal: x-coordinate of start point

36
vertical: y-coordinate of start point

width: width of the area

height: height of the area

Example:

//Enter page mode

Print.SelectPageMode()

//Set print area

Print.SetPageModePrintArea(0,0,200,200)

//Set print direction

Print.SetPageModePrintDirection(0)

//Set position of x, y

Print.SetPageModeAbsolutePosition(0,0)

//Print 2D code (can also print text and bar code)

Print.PrintQRCode("abcdef",4,48,1)

//Print

Print.PrintDataInPageMode()

Return:

≠-1:sending (to printer) success

-1:sending (to printer) failure

37
3.27 Set print direction in page mode

int SetPageModePrintDirection(int direction)

Note: The printer should support page mode function. And it can

take effect only when entering the page mode.

Parameter:

direction: print direction

0:0°

1:90°

2:180°

3:270°

Example:

//Enter page mode

Print.SelectPageMode()

//Set print area

Print.SetPageModePrintArea(0,0,200,200)

//Set print direction

Print.SetPageModePrintDirection(0)

//Set position of x, y

Print.SetPageModeAbsolutePosition(0,0)

//Print 2D code (can also print text and bar code)

Print.PrintQRCode("abcdef",4,48,1)

//Print

38
Print.PrintDataInPageMode()

Return:

≠-1:sending (to printer) success

-1:sending (to printer) failure

3.28 Set print position in page mode

int SetPageModeAbsolutePosition(int xPosition, int yPosition)

Note: The printer should support page mode function. And it can

take effect only when entering the page mode.

Parameter:

xPosition:X-coordinate

yPosition:Y-coordinate

Example:

//Enter page mode

Print.SelectPageMode()

//Set print area

Print.SetPageModePrintArea(0,0,200,200)

//Set print direction

Print.SetPageModePrintDirection(0)

//Set position of x, y

Print.SetPageModeAbsolutePosition(0,0)

//Print 2D code (can also print text and bar code)

39
Print.PrintQRCode("abcdef",4,48,1)

//Print

Print.PrintDataInPageMode()

Return:

≠-1:sending (to printer) success

-1:sending (to printer) failure

3.29 Print in page mode

int PrintDataInPageMode()

Note: The printer should support page mode function. And it can

take effect only when entering the page mode.

Example:

//Enter page mode

Print.SelectPageMode()

//Set print area

Print.SetPageModePrintArea(0,0,200,200)

//Set print direction

Print.SetPageModePrintDirection(0)

//Set position of x, y

Print.SetPageModeAbsolutePosition(0,0)

//Print 2D code (can also print text and bar code)

Print.PrintQRCode("abcdef",4,48,1)

40
//Print

Print.PrintDataInPageMode()

Return:

≠-1:sending (to printer) success

-1:sending (to printer) failure

3.30 Get NV bitmap list

int RefreshImageList(List<byte[]> lbImageIndex)

Note: Only when printer supports NV bitmap function can it take

effect.

Parameter:

lbImageIndex: serial number of image list

Example:

Print.RefreshImageList(lbImageIndex)

Return:

-1: Printer does not support NV bitmap function.

1: Successfully get NV bitmap list.

3.31 Get NV bitmap memory capacity

int QueryNVStoreCapacity(int[] iSpace)

Note: Only when printer supports NV bitmap function can it take

effect.

41
Parameter:

iSpace: memory capacity

Example:

iSpace=new int[1];

Print.QueryNVStoreCapacity(iSpace);

Return:

-1: Printer does not support NV bitmap function.

1: Successfully get NV bitmap list.

3.32 Get NV bitmap remaining capacity

int QueryNVStoreRemainingCapacity(int[]

storeRemainingCapacity)

Note: Only when printer supports NV bitmap function can it take

effect.

Parameter:

storeRemainingCapacity: remaining memory capacity

Example:

storeRemainingCapacity=new int[1];

Print.QueryNVStoreRemainingCapacity(storeRemainingCapacity);

Return:

-1: Printer does not support NV bitmap function.

1: Successfully get NV bitmap list.

42
3.33 Print NV bitmap

int PrintNVImage(String imageNo,int scaleMode)

Note: Only when printer supports NV bitmap function can it take

effect.

Parameter:

imageNo: serial number of image

scaleMode: mode (default: 0)

Example:

Print.PrintNVImage(imageNo,0);

Return:

≠-1: sending (to printer) success

-1: sending (to printer) failure

3.34 Delete specified NV bitmap

int DeleteSpecifiedNVImage(String sImageIndex)

Note: Only when printer supports NV bitmap function can it take

effect.

Parameter:

sImageIndex: serial number of image

Example:

Print.DeleteSpecifiedNVImage(sImageIndex);

Return:

43
≠-1: sending (to printer) success

-1: sending (to printer) failure

3.35 Delete all NV bitmap

int DeleteAllNVImage()

Note: Only when printer supports NV bitmap function can it take

effect.

Example:

Print.DeleteAllNVImage();

Return:

≠-1: sending (to printer) success

-1: sending (to printer) failure

3.36 Download NV bitmap to the printer

int DefineNVImage(String[] sArrFile, Handler handler)

Note: Only when printer supports NV bitmap function can it take

effect.

Parameter:

sArrFile: image path

Handler: Handler object

message.what: maximum number of data package

mesage.arg1: download progress

44
Example:

Print.DefineNVImage(sArrFile,handler);

Return:

≠-1: sending (to printer) success

-1: sending (to printer) failure

3.37 Print Binary file

boolean PrintBinaryFile(String strPRNFile)

Parameter:

strPRNFile: bin file path

Example:

Print.PrintBinaryFile(strPRNFile);

Return:

≠-1: sending (to printer) success

-1: sending (to printer) failure

3.38 Get printer function list

int CapturePrinterFunction(int ModelPropertyKeyBeep,

int[] propType, byte[] value, int[] dataLen)

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

propType: type number

Value: whether to support

(beeper, cut paper, drawer, page mode, power, receipt)

Value[0]==0 support.

Otherwise nonsupport

(Bar code)

String barcode =new String(Value);

barcode contains QRCODE, support 2D code

barcode contains PDF417, support PDF417

dataLen: length of return data

Example:

int[] propType=new int[1];

byte[] Value=new byte[500];

int[] DataLen=new int[1];

46
Print.CapturePrinterFunction(ModelPropertyKeyBeep,propType,V

alue,DataLen);

Return:

≠-1: sending (to printer) success

-1: sending (to printer) failure

47
3.39 Clear page mode print area data

int ClearPageModePrintAreaData()

Example:

Print.ClearPageModePrintAreaData();

Return:

≠-1: sending (to printer) success

-1: sending (to printer) failure

3.40 Print and return standard mode

int PrintAndReturnStandardMode()

Example:

Print.PrintAndReturnStandardMode();

Return:

≠-1: sending (to printer) success

-1: sending (to printer) failure

3.41 Set the left margin

int SetLeftMargin(int iLeftMargin)

Parameter:

iLeftMargin:Left margin (unit px)


Example:

Print.PrintAndReturnStandardMode();

48
Return:

≠-1: sending (to printer) success

-1: sending (to printer) failure

3.42 Read magnetic card information

Note: This feature is only supported on printers that have


a magnetic card feature.
void setTrackCardReaderMode(int track,CardReader

cardReader,int outTime)

Parameter:

track:Track (range: 1-5).


CardReader:The data is returned to the
interface.
Succeed(byte[] data);//The data returned.
Failure(int error);
//error--> 1:Connection disconnected, 2: timeout, 3: other
errors.

outTime:Timeout (in milliseconds).


Example:

Print.setTrackCardReaderMode(track,new
Print.CardReader() {
@Override

49
public void Succeed(final byte[] data) {
}
@Override
public void Failure(final int error) {
}
},30*1000);

3.43 Exit magnetic card mode

boolean CancelTrackCardReaderMode()

Example:

Print.CancelTrackCardReaderMode();
Return:

true:success。
false:failure。

3.44 Set mobile unit

int setPrintResolution(int x,int y)


Note:
his interface is a mobile unit that sets the x-axis
and y-axis.

50
unit:25.4/ x mm,
25.4/ y mm。
range:(0-255)。
Return:
> 0: sending (to printer) success

-1: sending (to printer) failure

-2:Parameter error

Example:

Print.setPrintResolution(203,203);

3.45 Print rectangle

int PrintPageRectangle(int x,int y,int width,


int height,int lineWidth)
Note:
This interface is only supported by some printers.
unit:PX。
Parameter :
x:The top left x coordinate.
y: The top left y coordinate.
width:The width of the rectangle.
height:The height of the rectangle.

51
lineWidth:Line width.
Return:
≠-1: sending (to printer) success

-1: sending (to printer) failure

Example:

Print.PrintPageRectangle(0,0,100,100,2);

3.46 Print Line

int PrintPageLine(int x1,int y1,int x2,int y2,


int lineWidth)
Note:
This interface is only supported by some printers.
unit:PX。
Parameter :
x1: Starting x coordinate.
y1: Starting y coordinate.
x2: End x coordinate.
y2: End y coordinate.
lineWidth:Line width.
Return:
≠-1: sending (to printer) success

52
-1: sending (to printer) failure

Example:

Print.PrintPageLine(0,0,100,100,2);

3.47 Image data compression print

int PrintBitmapLZO(Bitmap bitmap,int halftoneType)


Note:
This interface is only supported by some printers,
and the printer prints the original size of the image.
8 px=1 mm。
Parameter :
bitmap:image object.
halftoneType: Image algorithm type.
0:Binary algorithm.
1:Halftone algorithm.
Return:
≠-1: sending (to printer) success

-1: sending (to printer) failure

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

-1: sending (to printer) failure

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

You might also like