The iMin series has a variety of built-in printers. According to the product form, iMin has been packaged into a unified function interface. Debugging and development only requires direct invocation of the provided API interface.

Call the built-in printer through a USB connection

1.Connect to built-in print service

built-in printers demodownloads
Class description
UsbPrinter:Manage connection initialization of USB printer, printer status query and print data transmission
PrinterUtils:To realize the important class object of printing function, various printing and printing settings are provided for the printing tool class

Initialization

                  UsbPrinter printer = new UsbPrinter(); printer.initPrinter();//Implementing Initialization of Binding Connection Printing Service

2.Interface Definition Description

The printing function can be realized by establishing a connection with the built-in printing service and calling the following interface after initialization.

2.1 Get printer status information

Function:int getPrinterStatus()
Return value:
0-> normal
1 -> Data transmission error, please check connection or resend
2 -> Less paper
3 -> Missing paper
4 -> Error occurred
5 -> Open the cover
6 -> offline
7 -> feeding
8 -> Mechanical error
9 -> Automatically recoverable error
10 -> Unrecoverable error
11 -> Print head overheating
12 -> Cutter not reset
13 -> Black mark error

Example:

                  int status = printer.getPrinterStatus();

2.2 Printer Text

Functionvoid printerText(String text, UsbPrinterprinter)
Arguments:
text -> Printer content
printer -> Printer object
Example:

                  PrinterUtils.printerText(“Hello World”,printer);

2.3 Send data to the printer cache and do not print immediately

Functionvoid transmitText(String text, UsbPrinterprinter)
Arguments:
text -> Strings to be sent to the cache
printer -> Printer object


2.4 Print and line feed, print the data in the printer's cache

Functionvoid printAndLineFeed( UsbPrinterprinter)
Arguments:
printer -> Printer object
Notes:Usually print AndLineFeed( UsbPrinterprinter) and transmitText(String text, UsbPrinterprinter) are used together. First, data is sent to the printer cache using transmitText, and then print function is performed.

Example:

                  PrinterUtils.transmitText(“Hello World”); PrinterUtils.printAndLineFeed(printer);

2.5 Print all data standards in the printer cache

Function:void standardPrint( UsbPrinterpinter)
Arguments:
printer -> Printer object
The difference between standardPrint( UsbPrinterpinter) and transmissionText(String text, UsbPrinterprinter) is that standardPrint( UsbPrinterpinter) and **print AndLineFeed ( UsbPrinterprinter) are printed in a different line and standardAndLined( UsbPrinterprinter) is printed in a different line. standardPrint( UsbPrinterpinter) does not change lines


2.6 Print and wrap lines

**Function:**void printAndFeedPaper( UsbPrinterprinter, int value)
Arguments:
printer -> Printer object
Value -> wrap lines


2.7 Print Self-Check Pages

Function:void printSelfeTest( UsbPrinterprinter)
Arguments:
printer -> Printer object
Example:

                  PrinterUtils.printSelfeTest(printer)

2.8 Half cut

Function:void partialCut( UsbPrinterprinter)

2.9 Total cut

Function:void fullCut( UsbPrinterprinter)

Note: Only desktop and self-service machines with cutter function are supported.


2.10 Underscore

Function:void switchUnderLine( UsbPrinterprinter, int underLineCmd)
Arguments:
printer -> Printer object
underLineCmd -> 0->Ununderlined 1->Single underscore 2->Double underscore
Example:

                  PrinterUtils.switchUnderLine(printer,1)//Single underscore PrinterUtils.switchUnderLine(printer,2)//Double underscore

2.11 Set the right margin of the character

Function:void setRightMargin( UsbPrinterprinter, int charRightMargin)
Arguments:
printer -> Printer object
charRightMargin -> 0 <= charRightMargin <= 255 ; charRightMargin Abbreviated as n hereinafter, set the right spacing of characters to n points (8 points to 1 mm)


2.12 Setting Print Character Style

Function:void setFontStyle( UsbPrinterprinter, PrinterFontEnum... fontEnum)
Arguments:
printer-> Printer object
fontEnum ->
LARGE_FONT : Character font A (12 × 24) selected
NOMAR_FONT: Character font B (9 × 17) selected
DOUBLE_HEIGHT_CANCEL: Double-height canceled.
DOUBLE_HEIGHT: Double-height selected
DOUBLE_WIDTH: Double-width selected
DOUBLE_WIDTH_CANCEL: Double-width canceled
EMPHASIZED_OFF: Emphasized mode is turned off
EMPHASIZED_ON: Emphasized mode is turned on
Example:

                  PrinterUtils.setFontStyle(printer,PrinterFontEnum.LARGE_FONT,PrinterFontEnum.DOUBLE_HEIGHT);

2.13 Setting line height

Function:void setLineHeightSpace( UsbPrinterprinter, int lineHeight)
Arguments:
printer -> Printer object
lineHeight -> 0<= lineHeight <= 255 Set the line height of the character to line Height point (8 points to 1 mm)


2.14 Set font size

Function:void selectCharacterFont( UsbPrinterprinter, int fontStyle)
Arguments:
printer -> Printer object
fontStyle -> 0/48->The font size is 12x24,1/49The font size is 9x17


2.15 Reset the printer

Function:void initializePrinter( UsbPrinterprinter)


2.16 Send two-dimensional code data to printer buffer

Function:void storeQrCodeDataInStorage( UsbPrinterprinter, String qrStr)
Arguments:
printer -> Printer object
qrStr -> Character values of two-dimensional codes


2.17 Two-Dimensional Code of Print Storage Area

**Function:**void printQrCode( UsbPrinterprinter)


2.18 Setting two-dimensional code size

Function:void setQrCodeSize( UsbPrinterprinter, int level)
Arguments:
printer -> Printer object
level -> 1<= level <= 16


2.19 Set alignment mode

Function:void setAlignment( UsbPrinterprinter, int alignmentMode)
Arguments
printer -> Printer object
alignment -> 0 ≤ alignmentMode ≤ 2, 48 ≤ alignmentMode ≤ 50
0, 48 Left justification
1, 49 Centering
2, 50 Right justification
Example:

                  PrinterUtils.setAlignment(printer,0);

2.20 print pictures

Functionvoid printBitImage( UsbPrinterprinter, Bitmap bitmap)
Arguments:
printer -> Printer object
bitmap -> Picture Data Note to Print

Notes: Pictures Supporting only 1-bit color monochrome mode


2.21 Print the picture and send the NV graph to the printer buffer

Function:void defineNVBmp( UsbPrinterprinter, Bitmap bitmap, byte kc1, byte kc2)
Arguments:
printer -> Printer object
bitmap -> BMP Pictures Supporting 1-bit Color Only
kc1,kc2 -> In order to store the key value of the BMP in the buffer, the corresponding BMP bitmap can be printed by the key value later.
Example:

                  Bitmap bitmap = BitmapFactory.decodeResource(getResource(),R.drawable.test); PrinterUtils.defineNVBmp(printer,bitmap,31,32);

2.22 Print buffer NV pictures according to kc1 and kc2

Function:void printNVBmp( UsbPrinterprinter, int kc1, int kc2)
Arguments:
printer -> Printer object
kc1,kc2 -> Key Values of NV Graphs in Buffers
Example:

                  PrinterUtils.printNVBmp(printer,31,32) //Print the NV bitmap defined above in the buffer

2.23 Delete buffer NV images according to kc1 and kc2

Function:void deleteNVBmpByKeyCode( UsbPrinterprinter, byte kc1, byte kc2)
Arguments:
printer -> Printer object
kc1,kc2 -> Key Values of NV Graphs in Buffers
Example:

                  PrinterUtils.deleteNVBmpByKeyCode(printer,31,32) //Delete the NV bitmap defined above in the buffer

2.24 Delete all NV images

**Function:**void deleteAllNVBmp( UsbPrinterprinter)
Arguments:
printer -> Printer object


2.25 Setting the Height of One-Dimensional Code

Function:void setBarCodeHeight( UsbPrinterprinter, int height)
Arguments:
printer -> Printer object
height -> 1<= height <= 255, 8 is 1 mm.

2.26 Setting the width of One-Dimensional Code

Function:void setBarCodeWidth( UsbPrinterprinter, int width)
Arguments:
printer -> Printer object
width -> 2 <= width <= 6, Default value is 3

2.27Print one-dimensional code

Function:void printBarCode( UsbPrinterprinter, int barCodeType, String barCodeContent) throws UnsupportedEncodingException
Arguments:
printer -> Printer object
barcodeType -> 0<= barcodeType <= 6

barcodeType value length ASCII
0 -> UPC-A barCodeContent.length = 11,12 48 ≤range≤ 57
1->UPC-E barCodeContent.length = 11,12 48 ≤range≤ 57
2->JAN13 / EAN13 barCodeContent.length = 12,13 48 ≤range≤ 57
3->JAN8 / EAN8 barCodeContent.length = 7 48 ≤range≤ 57
4->CODE39 barCodeContent.length >=1 45 ≤range≤ 57 65≤range≤90,range = 32, 36, 37, 42, 43
5 -> ITF barCodeContent.length >=2 48 ≤range≤ 57
6 -> CODABAR barCodeContent.length >=2, 45≤range≤58, 65≤range≤ 68,97≤range≤100,range = 36

barCodeContent -->the barcode content
Example:

                  PrinterUtils.printBarCode(printer,4,”6666666”)

2.28 Select print position of HRI characters

Function:void setBarCodeContentPrintPos( UsbPrinterprinter, int position)
Arguments:
printer -> Printer object
position 0 ≤ position ≤ 3
0 Not printed.
1 Above the bar code.
2 Below the bar code.
3 Both above and below the bar code.


2.29 Select character size (height magnification and width magnification)

Function:void setCharacterSize( UsbPrinterprinter, int heightScale, int widthScale)
Arguments:
printer -> Printer object
heightScale -> 0 ≤ heightScale≤ 7
widthScale -> 0 ≤ widthScale≤ 7


2.30 Select the print speed

Function:void setPrintSpeed( UsbPrinterprinter, int speedEnum)
Arguments:
printer -> Printer object
speedEnum -> 0 <= speedEnum <= 9

2.31 Dual Printing

Function:void doubleStrikeMode( UsbPrinterprinter, int value)
Arguments:
printer -> Printer object
value -> 0 is close ,1 is open