public interface PrinterDevice extends Device, TimeConstants
The Printer device object is obtained from the POSTerminal
, its' as follows:
PrinterDevice printerDevice = (PrinterDevice) POSTerminal.getInstance().getDevice("com.cloudpos.device.printer");Among them, the "com.cloudpos.device.printer" string is to identify the printer device, defined by the specific implementation.
Uses the printer device object to control the operation of the printer device.
An app can request permission to access the device, as shown below:
<uses-permission android:name="android.permission.CLOUDPOS_PRINTER"/>To avoid lost printing data, please get battery level before print, if less than 5%, please don't print.>
Device
Modifier and Type | Field and Description |
---|---|
static int |
BARCODE_CODABAR
CODABAR, only for the printer can print barcode straightly.
|
static int |
BARCODE_CODE128
CODE128, only for the printer can print barcode straightly.
|
static int |
BARCODE_CODE39
CODE39, only for the printer can print barcode straightly.
|
static int |
BARCODE_CODE93
CODE93, only for the printer can print barcode straightly.
|
static int |
BARCODE_HRI_POS_ABOVE
HRI is in above the barcode.
|
static int |
BARCODE_HRI_POS_BELOW
HRI is in below the barcode.
|
static int |
BARCODE_HRI_POS_BOTH
HRI is in both above and below the barcode.
|
static int |
BARCODE_HRI_POS_NONE
No HRI.
|
static int |
BARCODE_ITF
TIF, only for the printer can print barcode straightly.
|
static int |
BARCODE_JAN13
JAN13, only for the printer can print barcode straightly.
|
static int |
BARCODE_JAN8
JAN8, only for the printer can print barcode straightly.
|
static int |
BARCODE_UPC_A
UPC-A, only for the printer can print barcode straightly.
|
static int |
BARCODE_UPC_E
UPC-E, only for the printer can print barcode straightly.
|
static int |
STATUS_OUT_OF_PAPER
out of paper.
|
static int |
STATUS_PAPER_EXIST
has paper.
|
FOREVER, IMMEDIATE, MilliSECOND, SECOND
Modifier and Type | Method and Description |
---|---|
void |
convertHTML2image(Context context,
java.lang.String htmlContent,
com.cloudpos.sdk.printer.html.PrinterHtmlListener listener)
convertHTML2image, add WebView.enableSlowWholeDocumentDraw() in the calling app, and add this permission android.permission.SYSTEM_ALERT_WINDOW
in manifest file.
|
void |
convertHTML2image(java.lang.String htmlContent,
com.cloudpos.sdk.printer.html.PrinterHtmlListener listener)
convertHTML2image, add WebView.enableSlowWholeDocumentDraw() in the calling app, and add this permission android.permission.SYSTEM_ALERT_WINDOW
in manifest file.
|
void |
cutPaper()
Cut paper, only in the printer that supported.
|
Format |
getDefaultParameters()
Gets the default format.
|
void |
open(int logicalID)
Opens the control of the Printer.
|
void |
printBarcode(Format format,
int barcodeType,
java.lang.String barcode)
print barcode.
|
void |
printBitmap(Bitmap bitmap)
Print bitmap.
|
void |
printBitmap(Format format,
Bitmap bitmap)
print bitmap.
|
void |
printHTML(Context context,
java.lang.String htmlContent,
com.cloudpos.sdk.printer.html.PrinterHtmlListener listener)
Print html content, add WebView.enableSlowWholeDocumentDraw() in the calling app, and add this permission
android.permission.SYSTEM_ALERT_WINDOW in manifest file.
|
void |
printHTML(java.lang.String htmlContent,
com.cloudpos.sdk.printer.html.PrinterHtmlListener listener)
Print html content, add WebView.enableSlowWholeDocumentDraw() in the calling app, and add this permission
android.permission.SYSTEM_ALERT_WINDOW in manifest file.
|
void |
printlnText(Format format,
java.lang.String message)
Print text, line wrap.
|
void |
printlnText(java.lang.String message)
Print text, line wrap.
|
void |
printText(Format format,
java.lang.String message)
Print text.
|
void |
printText(java.lang.String message)
Print text.
|
byte[] |
queryESC(byte[] esc,
int length,
int timeout)
Queries result ESC command.
|
int |
queryStatus()
Query the paper status in printer.
|
int |
queryVoltage(int[] capacity,
int[] voltage)
Query the battery status in printer.
|
int |
sendESCCommand(byte[] esc)
Send ESC, to operate the printer.
|
cancelRequest, close, getFailCount, getUsageCount, open
static final int BARCODE_UPC_A
static final int BARCODE_UPC_E
static final int BARCODE_JAN13
static final int BARCODE_JAN8
static final int BARCODE_CODE39
static final int BARCODE_ITF
static final int BARCODE_CODABAR
static final int BARCODE_CODE93
static final int BARCODE_CODE128
static final int BARCODE_HRI_POS_NONE
static final int BARCODE_HRI_POS_ABOVE
static final int BARCODE_HRI_POS_BELOW
static final int BARCODE_HRI_POS_BOTH
static final int STATUS_OUT_OF_PAPER
static final int STATUS_PAPER_EXIST
void open(int logicalID) throws DeviceException
logicalID
- logical ID of the device to open.DeviceException
- for the standard reasons that are documented in
DeviceException
.void printText(java.lang.String message) throws DeviceException
message
- string message.DeviceException
- for the standard reasons that are documented in
DeviceException
.void printlnText(java.lang.String message) throws DeviceException
message
- string message.DeviceException
- for the standard reasons that are documented in
DeviceException
.void printText(Format format, java.lang.String message) throws DeviceException
Through the format object to control print format string, printer subsequent print also in accordance with the format object contains formatting to perform.
format
- string format refer to Format
.message
- string message.DeviceException
- for the standard reasons that are documented in
DeviceException
.void printlnText(Format format, java.lang.String message) throws DeviceException
Through the format object to control print format string, printer subsequent print also in accordance with the format object contains formatting to perform.
format
- string format refer to Format
.message
- string message.DeviceException
- for the standard reasons that are documented in
DeviceException
.void printBitmap(Bitmap bitmap) throws DeviceException
bitmap
- DeviceException
- for the standard reasons that are documented in
DeviceException
.void printBitmap(Format format, Bitmap bitmap) throws DeviceException
Through the format object to control print format bitmap, printer subsequent print also in accordance with the format object contains formatting to perform.
format
- bitmap format refer to Format
.bitmap
- DeviceException
- for the standard reasons that are documented in
DeviceException
.void printBarcode(Format format, int barcodeType, java.lang.String barcode) throws DeviceException
Through the format object to control print format barcode, printer subsequent print also in accordance with the format object contains formatting to perform.
format
- barcode format refer to Format
.barcodeType
- refer to the constants.barcode
- barcode content.DeviceException
- for the standard reasons that are documented in
DeviceException
.int sendESCCommand(byte[] esc) throws DeviceException
The detail command format provided by the manufacturer.
esc
- ESC command data>=0
success.DeviceException
- for the standard reasons that are documented in
DeviceException
.void cutPaper() throws DeviceException
DeviceException
- for the standard reasons that are documented in
DeviceException
.int queryStatus() throws DeviceException
-101
out of paper, 1
normal, -102
abnormal .DeviceException
- for the standard reasons that are documented in
DeviceException
.Format getDefaultParameters() throws DeviceException
DeviceException
- for the standard reasons that are documented in
DeviceException
.byte[] queryESC(byte[] esc, int length, int timeout) throws DeviceException
esc
- ESC commandlength
- return lengthtimeout
- >=0
success.DeviceException
- for the standard reasons that are documented in
DeviceException
.void printHTML(Context context, java.lang.String htmlContent, com.cloudpos.sdk.printer.html.PrinterHtmlListener listener) throws DeviceException
context
- htmlContent
- html contentlistener
- PrinterHtmlListenerDeviceException
- for the standard reasons that are documented in
DeviceException
.void convertHTML2image(Context context, java.lang.String htmlContent, com.cloudpos.sdk.printer.html.PrinterHtmlListener listener) throws DeviceException
context
- htmlContent
- html contentlistener
- PrinterHtmlListenerDeviceException
- for the standard reasons that are documented in
DeviceException
.void printHTML(java.lang.String htmlContent, com.cloudpos.sdk.printer.html.PrinterHtmlListener listener) throws DeviceException
htmlContent
- html contentlistener
- PrinterHtmlListenerDeviceException
- for the standard reasons that are documented in
DeviceException
.void convertHTML2image(java.lang.String htmlContent, com.cloudpos.sdk.printer.html.PrinterHtmlListener listener) throws DeviceException
htmlContent
- html contentlistener
- PrinterHtmlListenerDeviceException
- for the standard reasons that are documented in
DeviceException
.int queryVoltage(int[] capacity, int[] voltage) throws DeviceException
capacity
- Battery capacity, int[1]voltage
- Battery voltage, int[1]>= 0
success, the result < 0
error code.DeviceException
- for the standard reasons that are documented in
DeviceException
.