Android POS Program Manual
Android POS Program Manual
v2.0.0
1. Instruction
This manual describes how to implement ESC/POS printing.Constant variable are defined in
IHR810Const class.
2. IHR810
2.1. IHR810
[Parameter]
Connection
Connected object, available via POSConnect.createDevice(deviceType)
.
2.2. printString
[Parameter]
data
Printed text string
[Return]
this
2.3. printText
[Parameter]
data
Printed text string
alignment
The alignment of the text, and the default is ALIGNMENT_LEFT
Variable Description
ALIGNMENT_LEFT Align left
ALIGNMENT_CENTER Align center
ALIGNMENT_RIGHT Align right
attribute
This value is text attributes. It sets text attributes to print. default is FNT_DEFAULT
Variable Description
FNT_DEFAULT FontA, Set up as a standard
FNT_FONTB Set up as FontB
FNT_BOLD bold font
FNT_REVERSE Set up as reverse print attribute
FNT_UNDERLINE Set up as Underline attribute
FNT_UNDERLINE2 Set up as Bold Underline attribute
textSize
The font size of the printed text font,default is TXT_1WIDTH|TXT_1HEIGHT
Variable(Set up width ratio) Description
TXT_1WIDTH Set up width ratio as x1
TXT_2WIDTH Set up width ratio as x2
TXT_3WIDTH Set up width ratio as x3
TXT_4WIDTH Set up width ratio as x4
TXT_5WIDTH Set up width ratio as x5
TXT_6WIDTH Set up width ratio as x6
TXT_7WIDTH Set up width ratio as x7
TXT_8WIDTH Set up width ratio as x8
[Return]
this
2.4. printBitmap
[Parameter]
bitmapPath
with full path of bitmap file.
bmp
Android Bitmap Object.
alignment
The alignment mode of the pictures.
Variable Description
ALIGNMENT_LEFT Align left
ALIGNMENT_CENTER Align center
ALIGNMENT_RIGHT Align right
width
Print the picture width, which can be used to zoom the picture
model
Print mode
Variable Description
BMP_NORMAL Original(Normal) size
BMP_WIDTH_DOUBLE Double width
BMP_HEIGHT_DOUBLE Double height
BMP_WIDTH_HEIGHT_DOUBLE Double size
[Return]
this
2.5. printBarCode
[Parameter]
data
Barcode string to be printed
codeType
Barcode type
Variable Description
BCS_UPCA UPC A
BCS_UPCE UPCE
BCS_EAN8 EAN-8
BCS_EAN13 EAN-13
BCS_JAN8 JAN-8
BCS_JAN13 JAN-13
BCS_ITF ITF
BCS_Codabar Codabar
BCS_Code39 Code 39
BCS_Code93 Code 93
BCS_Code128 Code 128, For this type, the data must be
added with {A, {B, {C, etc
height
Barcode height, range [1,255].Default is 162
width
This values barcode width in Dot Units, range [2, 6], Default is 3
Alignment
It sets barcode alignment, Default is ALIGNMENT_CENTER
Variable Description
ALIGNMENT_LEFT Align left
ALIGNMENT_CENTER Align center
ALIGNMENT_RIGHT Align right
textPosition
This value is printing position of barcode HRI letters(barcode data).Default is HRI_TEXT_BELOW.
Variable Description
HRI_TEXT_NONE Do not print barcode data
HRI_TEXT_ABOVE Print barcode data above the barcode
HRI_TEXT_BELOW Print barcode data below the barcode
HRI_TEXT_BOTH Print barcode data top and bottom
[Return]
this
2.6. feed
[Parameter]
lineCount
This value is the number of lines for line feeding. Default is 1
dotCount
This value is the number of point for line feeding.
[Return]
this
2.7. printQRCode
[Parameter]
data
QRCode data to print
moduleSize
Module size. Range[1, 16], Default is 8.
ecLevel
Error Correction Level, Default is QRCODE_EC_LEVEL_L
Variable Description
QRCODE_EC_LEVEL_L Error correction Level L (7%)
QRCODE_EC_LEVEL_M Error correction Level M (15%)
QRCODE_EC_LEVEL_Q Error correction Level Q (25%)
QRCODE_EC_LEVEL_H Error correction Level H (30%)
alignment
It sets QRCode alignment, Default is ALIGNMENT_CENTER
Variable Description
ALIGNMENT_LEFT Align left
ALIGNMENT_CENTER Align center
ALIGNMENT_RIGHT Align right
[Return]
this
2.8. cutPaper
[Parameter]
model
Cut paper mode, Default is CUT_HALF.
Variable Description
CUT_ALL Full cut
CUT_HALF Half cut
distance
Feed distance
[Return]
this
2.9. openCashBox
[Parameter]
pinNum
Pin number to generate pulse.
Variable Description
PIN_TWO PIN 2
PIN_FIVE PIN 5
onTime
Start tiime to generate pulse. onTime*2ms, range [0,255], Default is 30
offTime
Stop time to generate pulse. offTime*2ms, range [0,255], Default is 255
[Return]
this
2.10. setCharSet
[Parameter]
charSet
Character set name.
2.11. setTextStyle
[Parameter]
attribute
This value is text attributes. It sets text attributes to print. default is FNT_DEFAULT
Variable Description
FNT_DEFAULT FontA, Set up as a standard
FNT_FONTB Set up as FontB
FNT_BOLD bold font
FNT_REVERSE Set up as reverse print attribute
FNT_UNDERLINE Set up as Underline attribute
FNT_UNDERLINE2 Set up as Bold Underline attribute
textSize
The font size of the printed text font,default is TXT_1WIDTH|TXT_1HEIGHT
Variable(Set up width ratio) Description
TXT_1WIDTH Set up width ratio as x1
TXT_2WIDTH Set up width ratio as x2
TXT_3WIDTH Set up width ratio as x3
TXT_4WIDTH Set up width ratio as x4
TXT_5WIDTH Set up width ratio as x5
TXT_6WIDTH Set up width ratio as x6
TXT_7WIDTH Set up width ratio as x7
TXT_8WIDTH Set up width ratio as x8
[Return]
this
2.12. setAlignment
[Parameter]
alignment
The alignment of the text, and the default is ALIGNMENT_LEFT
Variable Description
ALIGNMENT_LEFT Align left
ALIGNMENT_CENTER Align center
ALIGNMENT_RIGHT Align right
[Return]
this
2.13. printerCheck
[Parameter]
type
Variable Description
STS_TYPE_PRINT Print state
STS_TYPE_OFFLINE off-line state
STS_TYPE_ERR Error state
STS_TYPE_PAPER Transfer paper state
timeout
Receive timeout, Unit is ms
callback
Read the data callback, the callback content is the corresponding printer state, if the data is not
received in the timeout time, then the empty byte is returned.
public interface IDataCallback {
void receive(byte[] data);
}
2.14. printerStatus
This method is used to query the common state of the printer, Timeout time is 5000ms
void printerStatus(IStatusCallback callback)
[Parameter]
callback
Read the status callback.
public interface IStatusCallback {
void receive(int status);
}
The status-values are shown in the table below.
STS_UNKNOWN Unknown state, read data timeout or received
data length is not 1
STS_NORMAL The printer is normal
STS_COVEROPEN Cover open
STS_PAPEREMPTY Printer lack of paper
2.15. cashBoxCheck
[Parameter]
callback
Read the status callback.
public interface IStatusCallback {
void receive(int status);
}
The status-values are shown in the table below.
STS_UNKNOWN Unknown state, read data timeout or received
data length is not 1.
STS_CASH_OPEN Cash drawer is open.
STS_CASH_CLOSE Cash drawer is close.
2.16. setPrintArea
[Parameter]
x
The x-coordinate of the starting position,Default is 0.
y
The y-coordinate of the starting position,Default is 0.
width
Width of printing area.
height
Height of printing area.
[Return]
this
2.17. setPageModel
[Parameter]
isOpen
Enable or Disable page mode. (TRUE, FALSE)
[Return]
this
2.18. printPageModelData
[Return]
this
2.19. setPrintDirection
[Parameter]
direction
Print direction
Variable Description
DIRECTION_LEFT_TOP From top left to right
DIRECTION_LEFT_BOTTOM From bottom left to top
DIRECTION_RIGHT_BOTTOM From bottom right to top
DIRECTION_RIGHT_TOP From top right to bottom
[Return]
this
2.20. setAbsoluteHorizontal
[Parameter]
position
Starting position.
[Return]
this
2.21. setRelativeHorizontal
[Parameter]
position
Starting position.
[Return]
this
2.22. setAbsoluteVertical
[Parameter]
position
Starting position.
[Return]
this
2.23. setRelativeVertical
[Parameter]
position
Starting position.
[Return]
this
2.24. downloadNVImage
[Parameter]
imagePaths
It sets the absolute path of the image files.
‘,’ = separator
(Example: "/storage/emulated/0/tmp/logo1.bmp,/storage/emulated/0/tmp/logo2.bmp")
bitmaps
The bitmap list
imageWidth
This value is image width.
[Return]
this
2.25. printNVImage
This function is used to support the Bitmap Image printing stored in Flash Memory.
IHR810 printNVImage(int index, int model)
[Parameter]
index
It sets the index image stored in Flash Memory to print,range[1,255]
model
Print model
Variable Description
BMP_NORMAL Normal size
BMP_WIDTH_DOUBLE Double width
BMP_HEIGHT_DOUBLE Double height
BMP_WIDTH_HEIGHT_DOUBLE Double size
[Return]
this
2.26. initializePrinter
2.27. selectBitmapModel
[Parameter]
model
Bitmap model
Variable Description
SINGLE_DENSITY_8 8-point single density
DOUBLE_DENSITY_8 8-point double density
SINGLE_DENSITY_24 24-point single density
DOUBLE_DENSITY_24 24-point double density
bytes
Bitmap byte array
[Return]
this
2.28. setLineSpacing
Set line-height
IHR810 setLineSpacing(int space)
space
Line-height,If you want to restore to the default height, use SPACE_DEFAULT.
[Return]
this
2.29. sendData
[Parameter]
data
Byte array to be sent
datas
Byte array collection to be sent
[Return]
this