Android ESCPOS Program Manual
Android ESCPOS Program Manual
ESC/POS
Mobile, Thermal Printer
Rev. 1.113
2.1. ESCPOSPrinter
This is Constructor method. ESCPOSPrinter object select a character set using for parameter.
If do not use a parameter, default character set is ISO-8859-1.
ESCPOSPrinter() , ESCPOSPrinter(String charset) ,
ESCPOSPrinter(DeviceConnection connection)
ESCPOSPrinter(String charset, DeviceConnection connection)
[Parameter]
* charset
- Character set name.
* connection
- Device connection. (USBPortConnection, WiFiMultiConnection)
2.2. printNormal
This function is used for supporting text printing and OLE POS command.
void printNormal(String data)
[Parameter]
* data
- Pointer to a null-terminated Unicode string. It is same as PrintNormal function
in OLE POS Command.
2.3. printString
This function is used for supporting text printing with ESC command.
void printString(String data)
[Parameter]
* data
- Pointer to a null-terminated Unicode string. It sets Unicode String to print.
2.4. printText
This function is used for supporting text printing
void printText(String data,int alignment,int attribute,int textSize)
* alignment
- This value is alignment. It sets text alignment.
Variable Description
LK_ALIGNMENT_LEFT Left alignment
LK_ALIGNMENT_CENTER Center alignment
LK_ALIGNMENT_RIGHT Right alignment
* attribute
- This value is text attributes. It sets text attributes to print.
Variable Description
LK_FNT_DEFAULT FontA, Set up as a standard
LK_FNT_FONTB Set up as FontB
LK_FNT_BOLD Set up as Bold attribute
LK_FNT_UNDERLINE Set up as Underline attribute
LK_FNT_REVERSE Set up as reverse print attribute
* textSize
- This value is text size. It sets text size to print.
Variable (Set up width ratio) Description
LK_TXT_1WIDTH Set up width ratio as x1
LK_TXT_2WIDTH Set up width ratio as x2
LK_TXT_3WIDTH Set up width ratio as x3
LK_TXT_4WIDTH Set up width ratio as x4
LK_TXT_5WIDTH Set up width ratio as x5
LK_TXT_6WIDTH Set up width ratio as x6
LK_TXT_7WIDTH Set up width ratio as x7
LK_TXT_8WIDTH Set up width ratio as x8
// Added in 1.093A
void printBitmap(String bitmapName, int alignment, int size, int brightness, int reverseprint)
void printBitmap(String bitmapName, int alignment, int size, int brightness, int reverseprint,
int compress)
void printBitmap(Bitmap bmp, int alignment, int size, int brightness, int reverseprint)
void printBitmap(Bitmap bmp, int alignment, int size, int brightness, int reverseprint,
int compress)
[Parameter]
* BitmapName
- Pointer to a null-terminated Unicode string. This value is the bitmap file name
with full path of bitmap file. [BMP/JPEG/PNG/GIF]
* Bmp
- Android Bitmap Object. [android.graphics.Bitmap]
* Alignment
- This value is alignment. It sets image alignment.
Variable(Value) Description
LK_ALIGNMENT_LEFT(0) Left alignment
LK_ALIGNMENT_CENTER(1) Center alignment
LK_ALIGNMENT_RIGHT(2) Right alignment
* Size
- This value is image size. It sets image size to print.
Variable(Value) Description
LK_BITMAP_NORMAL(0) Original(Normal) size
LK_BITMAP_DOUBLE_WIDTH(1) Double width
LK_BITMAP_DOUBLE_HEIGHT(2) Double height
LK_BITMAP_QUADRUPLE(3) Double size
Others Printing size of image
* brightness
- This value is a brightness of image.
2.6. printBarCode
This function is used for supporting barcode printing.
void printBarCode(String data,int symbology,int height,int width,int alignment,int textPosition)
[Parameter]
* Data
- Pointer to a null-terminated Unicode string. It sets the barcode data to print.
* Symbology
- This value is barcode symbol type. It sets barcode type to print.
Variable Description
LK_BCS_UPCA Print UPC A BarCode
LK_BCS_UPCE Print UPC E BarCode
LK_BCS_EAN8 Print EAN-8 BarCode
LK_BCS_EAN13 Print EAN-13 BarCode
LK_BCS_JAN8 Print JAN-8 BarCode
LK_BCS_JAN13 Print JAN-13 BarCode
LK_BCS_ITF Print Interleaved 2 of 5
LK_BCS_Codabar Print Codabar BarCode
LK_BCS_Code39 Print Code 3 of 9 BarCode
LK_BCS_Code93 Print Code 93 BarCode
LK_BCS_Code128 Print Code 128 BarCode
LK_BCS_3OF5 Print 3 out of 5(KorMail) BarCode
* Height
- This value is barcode height in Dot Units. It sets barcode height to print.
* Width
- This values barcode width in Dot Units. It sets total barcode width to print.
* Alignment
- This value is alignment. It sets barcode alignment.
Variable Description
LK_ALIGNMENT_LEFT Left alignment
LK_ALIGNMENT_CENTER Center alignment
LK_ALIGNMENT_RIGHT Right alignment
* TextPosition
- This value is printing position of barcode HRI letters(barcode data).
2.7. lineFeed
This function is used for sending feeding command to printer.
void lineFeed(int LFCount)
[Parameter]
* LFCount
- This value is the number of lines for line feeding. It sets line feeding counter.
[Parameter]
* Timeout : milliseconds. (Default : 5000 ms)
* bCheckResult
- set the result of printing.
Variable Description
TRUE Check the printing result ( refer to printerResults function
FALSE Don’ t check the printing result
[Return Values]
LK_SUCCESS : This value returns when a function succeeds.
LK_FAIL : This value returns when a function fails.
LK_STS_PRINTEROFF : This value returns when printer is off. Added in 1.102
LK_STS_TIMEOUT : This value returns when printer is no response or power off. Added in
1.102
( LK_STS_PRINTEROFF is returned when printerCheck function is used while printer is off.
LK_STS_TIMEOUT is returned when printerCheck function is used again )
[Return Values]
LK_STS_NORMAL: Printer Status is No Error and MSR is not Ready.
LK_STS_PAPER_EMPTY : Printer Status is no paper.
LK_STS_COVER_OPEN : Printer Cover is open.
LK_STS_BATTERY_LOW : Printer battery capacity is low.
LK_STS_MSR_READ : Currently MSR in read mode, printing is impossible.
2.10. printNVBitmap
This function is used to support the Bitmap Image printing stored in Flash Memory.
void printNVBitmap(int NVImageNumber)
void printNVBitmap(int NVImageNumber, int size)
[Parameter]
* NVImageNumber
- It sets the Number image stored in Flash Memory to print.
* Size
- This value is image size. It sets image size to print.
Variable Description
LK_BITMAP_NORMAL Normal size
LK_BITMAP_DOUBLE_WIDTH Double width
LK_BITMAP_DOUBLE_HEIGHT Double height
LK_BITMAP_QUADRUPLE Double size
2.11 printPDF417
This method is used for supporting PDF417 barcode printing.
void printPDF417(String pdfData, int dataLength, int numberOfColumns, int cellWidth,
int alignment)
int printPDF417(String pdfData, int dataLength, int cellWidth, int cellHeightRatio,
int numberOfColumns, int numberOfRows, int eclType, int eclValue,
int alignment) Added in 1.098
[Parameter]
* pdfData
- Barcode data to print.
[Return Values]
LK_SUCCESS : This value returns when a function succeeds.
others : This value returns when a function fails.
[Parameter]
* data
- Barcode data to print.
* dataLength
- Length of barcode data.
* version
- QRCode Version. (Auto = 0, Fixed = 1 ~ 40)
* moduleSize
- Module size. (1 ~ 20)
* ECLevel
- Error Correction Level.
Variable Description
LK_QRCODE_EC_LEVEL_L Error correction Level L (7%)
LK_QRCODE_EC_LEVEL_M Error correction Level M (15%)
LK_QRCODE_EC_LEVEL_Q Error correction Level Q (25%)
LK_QRCODE_EC_LEVEL_H Error correction Level H (30%)
* align
- This value is alignment. It sets barcode alignment.
Variable Description
LK_ALIGNMENT_LEFT Left alignment
LK_ALIGNMENT_CENTER Center alignment
LK_ALIGNMENT_RIGHT Right alignment
2.17 asbOn
Enable ASB Mode. (ASB : Auto Status Back)
int asbOn()
[Return value]
LK_SUCCESS , LK_FAIL
2.18 asbOff
Disable ASB Mode.
int asbOff()
[Return value]
LK_SUCCESS , LK_FAIL
2.20 printPageModeData
Print and return to standard mode in page mode.
void printPageModeData()
2.21 clearPageModeData
Cancel print data in page mode.
void clearPageModeData()
2.22 setPageMode
Change to page mode or standard mode.
void setPageMode(boolean pagemode)
[Parameter]
* pagemode
- Enable or Disable page mode. (TRUE, FALSE)
2.23 setPrintDirection
Select print direction in page mode.
void setPrintDirection(int direction)
[Parameter]
* direction
- Print direction
Variable Description
DIRECTION_LEFT_RIGHT Starting upper left
DIRECTION_BOTTOM_TOP Starting lower left
DIRECTION_RIGHT_LEFT Starting lower right
DIRECTION_TOP_BOTTOM Starting upper right
2.24 setPrintingArea
Set printing area in page mode.
void setPrintingArea(int pageWidth, int pageHeight)
[Parameter]
* pageWidth
- Width of printing area.
2.25 setDPI
Set DPI in page mode.
void setDPI(int dpi)
[Parameter]
* dpi
- Dot per Inch (Constant value, ex: 180 , 203)
2.26 setAbsoluteHorizontal
Set absolute horizontal print position in page mode. (X axis)
void setAbsoluteHorizontal(int absolutePosition)
[Parameter]
* absolutePosition
- Starting position.
2.27 setRelativeHorizontal
Set relative horizontal print position in page mode. (X axis)
void setRelativeHorizontal(int relativePosition)
[Parameter]
* relativePosition
- Starting position.
2.28 setAbsoluteVertical
Set absolute vertical print position in page mode. (Y axis)
void setAbsoluteVertical(int absolutePosition)
[Parameter]
* absolutePosition
- Starting position.
2.29 setRelativeVertical
Set relative vertical print position in page mode. (Y axis)
void setRelativeVertical(int relativePosition)
2.30 setCharSet
Set character Set.
void setCharSet(String charSet)
[Parameter]
* charSet
- Character set name.
2.31 ICRMode
Set the ICR communication.
int ICRMode(boolean bICR)
[Parameter]
* bICR
- Set the ICR communication mode.
Variable Description
true ICR enable
false ICR disable
[Return value]
LK_SUCCESS , LK_FAIL
2.32 ICR_SendReceive
It used to send ICR Command and receive the response from ICR.
int ICR_SendReceive(byte[] ucCommandLen, byte[] prgucCommand,
byte pucReaderResponseLen, byte[] prgucReaderResponse)
[Parameter]
* ucCommandLen
- Set the ICR Command length.
* prgucCommand
- Set the ICR Command.
* pucReaderResponseLen
- Set the ICR Response length.
2.33 getResponseSize
It used to send ICR Command and receive the response from ICR.
int getResponseSize()
[Parameter]
* none
[Return value]
Returns the size of reponse length in ICR_SendReceive function.
2.34 cardInserted
Get the status of card.
boolean cardInserted()
[Parameter]
* none
[Return value]
Variable Description
true Card is inserted
false Card is not inserted
[Parameter]
* textString
- Unicode which has a null-terminated string. It receives text to print as a factor.
* widthDots
- It receives the printing width value of the text to print as a factor. [ Default : dot ]
* textSize
- It receives the font size value of the text to print as a factor. [ Default : dot ]
* Alignment
- This value is alignment. It sets image alignment.
Variable Description
LK_ALIGNMENT_LEFT Left alignment
LK_ALIGNMENT_CENTER Center alignment
LK_ALIGNMENT_RIGHT Right alignment
* typeface
- It receives the typeface of the android’s font as a factor.
Variable Description
SANS_SERIF SANS_SERIF font
SERIF SERIF font
MONOSPACE MONOSPACE font
* isBold
- It receives the bold of the android’s font as a factor.
* isItalic
- It receives the italic of the android’s font as a factor.
* isUnderline
- It receives the underline of the android’s font as a factor.
* rotate180
- It receives the rotation(180degree) of the android’s font as a factor.
[Parameter]
* timeout
- It receives the waiting time of the printing result.
If timeout is zero, do not waiting the printing result Added in 1.102.
[Parameter]
* attribute
- This value is text attributes. It sets text attributes to print.
Variable Description
LK_FNT_DEFAULT FontA, Set up as a standard
LK_FNT_FONTB Set up as FontB
LK _FNT_BOLD Set up as Bold attribute
LK _FNT_UNDERLINE Set up as Underline attribute
LK _FNT_REVERSE Set up as reverse print attribute
* textSize
- This value is text size. It sets text size to print.
Variable (Set up width ratio) Description
LK _TXT_1WIDTH Set up width ratio as x1
LK _TXT_2WIDTH Set up width ratio as x2
LK _TXT_3WIDTH Set up width ratio as x3
LK _TXT_4WIDTH Set up width ratio as x4
LK _TXT_5WIDTH Set up width ratio as x5
LK _TXT_6WIDTH Set up width ratio as x6
LK _TXT_7WIDTH Set up width ratio as x7
LK _TXT_8WIDTH Set up width ratio as x8
* alignment
- This value is alignment. It sets text alignment.
Variable Description
LK _ALIGNMENT_LEFT Left alignment
LK _ALIGNMENT_CENTER Center alignment
LK _ALIGNMENT_RIGHT Right alignment
[Parameter]
* pdfName
- Path of pdf file to be printed.
* pageNum
- page number to be printed
* alignment
- This value is alignment. It sets image alignment.
Variable Description
LK_ALIGNMENT_LEFT Left alignment
LK_ALIGNMENT_CENTER Center alignment
LK_ALIGNMENT_RIGHT Right alignment
* widthSize
- This value is size of printing. It sets width size to print.
* brightness
- This value is a brightness of image.
[Return Values]
Variable Description
CMP_SUCCESS Setting is success.
Other values No response. Printer error.
[Parameter]
* printX
- It receives the x-coordinates value of the text to print as a factor.
* printY
- It receives the y-coordinates value of the text to print as a factor.
* textString
- Unicode which has a null-terminated string. It receives text to print as a factor.
* widthDots
- It receives the printing width value of the text to print as a factor. [ Default : dot ]
* textSize
- It receives the font size value of the text to print as a factor. [ Default : dot ]
* Alignment
- This value is alignment. It sets image alignment.
Variable Description
LK_ALIGNMENT_LEFT Left alignment
LK_ALIGNMENT_CENTER Center alignment
LK_ALIGNMENT_RIGHT Right alignment
* typeface
- It receives the typeface of the android’s font as a factor.
Variable Description
SANS_SERIF SANS_SERIF font
SERIF SERIF font
MONOSPACE MONOSPACE font
* isBold
- It receives the bold of the android’s font as a factor.
* isItalic
- It receives the italic of the android’s font as a factor.
[Return Values]
Variable Description
CMP_SUCCESS Printing is success.
Other values No response. Printer error.
[Parameter]
* iCompress
- This value is compression or not.
Variable Description
0 No compression
Others Compression
[Parameter]
* bitmapPathList
- It sets the absolute path of the image files. [BMP/JPEG/PNG/GIF]
‘|’ = separator
(ex) “//sdcard//temp//logo_s.jpg|//sdcard//temp//logo_m.jpg”
* iSizeMode
- This value is image size. It sets image size to save.
Variable(Value) Description
LK_BITMAP_NORMAL(0) Original(Normal) size
LK_BITMAP_DOUBLE_WIDTH(1) Double width
LK_BITMAP_DOUBLE_HEIGHT(2) Double height
LK_BITMAP_QUADRUPLE(3) Double size
[Parameter]
* none
2.45. printPDFFile
This function is used for printing pdf files.* Available for Android 5.0 or later.
void printPDFFile(String path, int alignment, int paper_size, int feed)
void printPDFFile(String path, int alignment, int paper_size, int feed, int compress)
void printPDFFile(File file, int alignment, int paper_size, int feed)
void printPDFFile(File file, int alignment, int paper_size, int feed, int compress)
void printPDFFile(ParcelFileDescriptor fd_PDF, int alignment, int paper_size, int feed,
int compress)
[Parameter]
* path
- This value is the full path of pdf file.
* file, fd_PDF
- File or ParcelFileDescriptor Object.
* Alignment
- This value is alignment. It sets image alignment.
* paper_size
- This value is printing size. If the value is 0, the original size is printed.
* feed
- This value is the number of lines for line feeding.
* compress
- This value is a compression of data. [ 0=Raw, 1=Compress ]
2.46. set180Rotation
This function is used for supporting 180 rotation.
void set180Rotation(boolean check)
[Parameter]
* check
- This value is 180 rotation value(true, false)