android.device
Class PrinterManager

java.lang.Object
  extended by android.device.PrinterManager

public class PrinterManager
extends java.lang.Object

The android.device.PriterManager provides support for printer


Constructor Summary
PrinterManager()
           
 
Method Summary
 int prn_clearPage()
          Clear the current page.
 void prn_close()
          Close the printer
 int prn_drawBarcode(java.lang.String data, int x, int y, int barcodetype, int width, int height, int rotate)
           
 int prn_drawBitmap(android.graphics.Bitmap bmp, int xDest, int yDest)
          Draw a bitmap on the current page
 int prn_drawLine(int x0, int y0, int x1, int y1, int lineWidth)
          Draw a line in the current page.
 int prn_drawText(java.lang.String data, int x, int y, java.lang.String fontname, int fontsize, boolean bold, boolean italic, int rotate)
          Draw text on the current page
 int prn_drawTextEx(java.lang.String data, int x, int y, int width, int height, java.lang.String fontname, int fontsize, int rotate, int style, int format)
           
 int prn_getStatus()
           
 int prn_getTemp()
          Get current the printer's temperature Note: The printer must be opened prior to calling this method
 int prn_open()
          Opens the printer
 int prn_printPage(int rotate)
          Print the current page.
 int prn_setBlack(int level)
          Set print gray level
 int prn_setSpeed(int level)
          Set print speed level
 int prn_setupPage(int width, int height)
          Set the page size.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PrinterManager

public PrinterManager()
Method Detail

prn_open

public int prn_open()
Opens the printer

Returns:
Returns 0 if open successful. Returns -1 if failed

prn_getTemp

public int prn_getTemp()
Get current the printer's temperature Note: The printer must be opened prior to calling this method

Returns:
Returns 0 if failed .

prn_setSpeed

public int prn_setSpeed(int level)
Set print speed level

Parameters:
level - value is 50 to 80,default 62
Returns:
Returns 0 if failed .

prn_setBlack

public int prn_setBlack(int level)
Set print gray level

Parameters:
level - value is 0 to 30, default 15.
Returns:
Returns 0 if failed .

prn_close

public void prn_close()
Close the printer


prn_setupPage

public int prn_setupPage(int width,
                         int height)
Set the page size. Unit is in pixel. 8 pixels is equivalent to 1 mm.

Parameters:
width - Page width, -1 means largest possible width (width = 384)。
height - Page height. -1 means printer driver to manage the page height.
Returns:
0 when success, and -1 when failed.

prn_clearPage

public int prn_clearPage()
Clear the current page.

Returns:
Returns 0 if successful. Returns -1 if failed.

prn_printPage

public int prn_printPage(int rotate)
Print the current page.

Parameters:
rotate - The rotation angle, currently supports only 0 (non-rotating)
Returns:
Returns 0 if success. Returns -1 if failed.

prn_drawLine

public int prn_drawLine(int x0,
                        int y0,
                        int x1,
                        int y1,
                        int lineWidth)
Draw a line in the current page.
(0,0) point axis: On the upper left corner of the screen

Parameters:
x0 - start point X axis,
y0 - start point Y axis
x1 - end point X axis,
y1 - end point Y axis
lineWidth - in pixel.
Returns:
Returns 0 if successful. Returns -1 if failed.

prn_drawText

public int prn_drawText(java.lang.String data,
                        int x,
                        int y,
                        java.lang.String fontname,
                        int fontsize,
                        boolean bold,
                        boolean italic,
                        int rotate)
Draw text on the current page

Parameters:
data - The string to be draw
x - Start point X axis,
y - Start point Y axis
fontname - Font to be used, otherwise, default system font is used. Custom fonts can be specified, for example, specifying the full path /mnt/sdcard/xxx.ttf.
fontsize - The font size, in pixel
bold - The font bold style
italic - The font italic style
rotate - The text direction. 0 no rotation, 1 rotate 90 degree, 2 rotate 180 degree, 3 rotate 270 degree.
Returns:
If successful, returns actual printing height. Returns -1 when failed.

prn_drawTextEx

public int prn_drawTextEx(java.lang.String data,
                          int x,
                          int y,
                          int width,
                          int height,
                          java.lang.String fontname,
                          int fontsize,
                          int rotate,
                          int style,
                          int format)
Parameters:
data - The string to be draw
x - Start point X axis,
y - Start point Y axis
width - Text is printed to the width of the rectangle on the page
height - Text is printed to the height of the rectangle on the page
fontname - font to be use, otherwise, default system font is used. Or custom fonts i.e. /mnt/sdcard/xxx.ttf the path.
fontsize - the font size, in pixel
rotate - print the text degree, 0 no rotation, 1 rotate 90 degree, 2 rotate 180 degree, 3 rotate 270 degree.
style - Font style (0x0001 - underline, 0x0002 - italic, 0x0004 - bold 0x0008 reverse effect, 0x0010 - strike out), you can mix the style by using the or operator, style= 0x0002|0x0004
format - Set to 0 means word wrap. Set to 1 means word wrap at the specified height and width
Returns:
Returns actual printing height if successful. Returns -1 if failed.

prn_drawBarcode

public int prn_drawBarcode(java.lang.String data,
                           int x,
                           int y,
                           int barcodetype,
                           int width,
                           int height,
                           int rotate)
Parameters:
data - The barcode text
x - Start point at X axis,
y - Start point at Y axis
barcodetype - Following Table shows the supported symbology
BARCODE_CODE111
BARCODE_C25MATRIX2
BARCODE_C25INTER3
BARCODE_C25IATA4
BARCODE_C25LOGIC6
BARCODE_C25IND7
BARCODE_CODE398
BARCODE_EXCODE399
BARCODE_EANX13
BARCODE_EAN12816
BARCODE_CODABAR18
BARCODE_CODE12820
BARCODE_DPLEIT21
BARCODE_DPIDENT22
BARCODE_CODE16K23
BARCODE_CODE4924
BARCODE_CODE9325
BARCODE_FLAT28
BARCODE_RSS1429
BARCODE_RSS_LTD30
BARCODE_RSS_EXP31
BARCODE_TELEPEN32
BARCODE_UPCA34
BARCODE_UPCE37
BARCODE_POSTNET40
BARCODE_MSI_PLESSEY47
BARCODE_FIM49
BARCODE_LOGMARS50
BARCODE_PHARMA51
BARCODE_PZN52
BARCODE_PHARMA_TWO53
BARCODE_PDF41755
BARCODE_PDF417TRUNC56
BARCODE_MAXICODE57
BARCODE_QRCODE58
BARCODE_CODE128B60
BARCODE_AUSPOST63
BARCODE_AUSREPLY66
BARCODE_AUSROUTE67
BARCODE_AUSREDIRECT68
BARCODE_ISBNX69
BARCODE_RM4SCC70
BARCODE_DATAMATRIX71
BARCODE_EAN1472
BARCODE_CODABLOCKF74
BARCODE_NVE1875
BARCODE_JAPANPOST76
BARCODE_KOREAPOST77
BARCODE_RSS14STACK79
BARCODE_RSS14STACK_OMNI80
BARCODE_RSS_EXPSTACK81
BARCODE_PLANET82
BARCODE_MICROPDF41784
BARCODE_ONECODE85
BARCODE_PLESSEY86
width - There are four thickness level to the lines, 1 being the thinnest and 4 being the thickest.
height - The barcode height in pixel
rotate - The barcode rotation, 0 no rotation, 1 rotate 90 degree, 2 rotate 180 degree, 3 rotate 270 degree.
Returns:
Returns actual printing height if successful. Returns -1 when failed.

prn_drawBitmap

public int prn_drawBitmap(android.graphics.Bitmap bmp,
                          int xDest,
                          int yDest)
Draw a bitmap on the current page

Parameters:
bmp - The bitmap to be drawn
xDest - Start point at X axis,
yDest - Start point at Y axis,
Returns:
Returns actual printing height is successful. Returns -1 if failed.

prn_getStatus

public int prn_getStatus()