Printer

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

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

1
2
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:

1
int status = printer.getPrinterStatus();

2.2 Printer Text

Function: void printerText (String text, UsbPrinter printer)

Arguments:

text: String to print

printer: Printer object

Example:

1
PrinterUtils.printerText("Hello World",printer);

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

Function: void transmitText (String text, UsbPrinter printer)

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

Function void printAndLineFeed ( UsbPrinter printer)

Arguments:

printer:Printer object

Note

Usually print AndLineFeed (UsbPrinter printer) and transmitText (String text, UsbPrinter printer) are used together. First, data is sent to the printer cache using transmitText, and then print function is performed.

Example:

1
2
 PrinterUtils.transmitText("Hello World");
 PrinterUtils.printAndLineFeed(printer);

2.5 Print all data standards in the printer cache

Function: void standardPrint (UsbPrinter pinter)

Arguments:

printer: Printer object

Note

The difference between standardPrint (UsbPrinter pinter) and transmissionText (String text, UsbPrinter printer) is that standardPrint (UsbPrinter pinter) and print AndLineFeed (UsbPrinter printer) are printed in a different line and standardAndLined (UsbPrinter printer) is printed in a different line. standardPrint ( UsbPrinter pinter) does not change lines

2.6 Print and wrap lines

Function: void printAndFeedPaper (UsbPrinter printer, int value)

Arguments:

printer: Printer object

Value: wrap lines

2.7 Print Self-Check Pages

Function: void printSelfeTest (UsbPrinter printer)

Arguments:

printer:Printer object

Example:

1
PrinterUtils.printSelfeTest(printer)

2.8 Half cut

Function: void partialCut (UsbPrinter printer)

2.9 Total cut

Function: void fullCut (UsbPrinter printer)

Note

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

2.10 Underscore

Function: void switchUnderLine (UsbPrinter printer, int underLineCmd)

Arguments:

printer: Printer object

underLineCmd-> 0: Ununderlined, 1: Single underscore, 2:Double underscore

Example:

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

2.11 Set the right margin of the character

Function: void setRightMargin (UsbPrinter printer, 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 (UsbPrinter printer, 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:

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

2.13 Setting line height

Function: void setLineHeightSpace (UsbPrinter printer, 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 (UsbPrinter printer, int fontStyle)

Arguments:

printer: Printer object

fontStyle: 0/48: The font size is 12x24, 1/49: The font size is 9x17

2.15 Reset the printer

Function: void initializePrinter (UsbPrinter printer)

2.16 Send two-dimensional code data to printer buffer

Function: void storeQrCodeDataInStorage (UsbPrinter printer, 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 (UsbPrinter printer)

2.18 Setting two-dimensional code size

Function: void setQrCodeSize (UsbPrinter printer, int level)

Arguments:

printer: Printer object

level: The value ranges from 1 to 16.

2.19 Set alignment mode

Function: void setAlignment (UsbPrinter printer, 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:

1
PrinterUtils.setAlignment(printer,0);

2.20 print pictures

Function void printBitImage (UsbPrinter printer, Bitmap bitmap)

Arguments:

printer: Printer object

bitmap: Picture Data Note to Print

Note

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 (UsbPrinter printer, 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:

1
2
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 (UsbPrinter printer, int kc1, int kc2)

Arguments:

printer:  Printer object

kc1,kc2: Key Values of NV Graphs in Buffers

Example:

1
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 (UsbPrinter printer, byte kc1, byte kc2)

Arguments:

printer -> Printer object

kc1,kc2 -> Key Values of NV Graphs in Buffers

Example:

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

2.24 Delete all NV images

Function: void deleteAllNVBmp (UsbPrinter printer)

Arguments:

printer:Printer object

2.25 Setting the Height of One-Dimensional Code

Function: void setBarCodeHeight (UsbPrinter printer, 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 (UsbPrinter printer, int width)

Arguments:

printer: Printer object

width: 2 <= width <= 6, Default value is 3

2.27Print one-dimensional code

Function: void printBarCode (UsbPrinter printer, int barCodeType, String barCodeContent)

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:

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

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

2.28 Select print position of HRI characters

Function: void setBarCodeContentPrintPos (UsbPrinter printer, 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 (UsbPrinter printer, 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 (UsbPrinter printer, int speedEnum)

Arguments:

printer: Printer object

speedEnum: 0 <= speedEnum <= 9

2.31 Dual Printing

Function: void doubleStrikeMode (UsbPrinter printer, int value)

Arguments:

printer: Printer object

value:  0 is close ,1 is open