PrinterSDK

1.Call the printer via SDK

iMin SDK provides packaged common printing instructions, so that developers can quickly access iMin printers

iminPrinterSDK Download

1、Printer initialization

Function:void initPrinter()

Remarks:Reset the printer’s logic program (for example: layout settings, bold and other style settings), but do not clear the buffer data, so unfinished print jobs will continue after reset.

1
IminPrintUtils.getInstance(TestPrintActivity.this).initPrinter();

2、Get printer status

Function:int getPrinterStatus()

return value:

-1 –> The printer is not connected or powered on

0 –> The printer is normal

2 –> Printer and call library do not match

3 –> Print head open

4 –> Cutter is not reset

5 –> The print head is too hot

6 –> Black mark error

7 –> No Paper Feed

8 –> Paper Running Out

1
int status = IminPrintUtils.getInstance(TestPrintActivity.this).getPrinterStatus();

3、Print and feed paper

Function:void printAndLineFeed()

Remarks:The printer runs on 1 lines of paper

1
IminPrintUtils.getInstance(TestPrintActivity.this).printAndLineFeed();

4、Print blank lines (custom height)

Function:void printAndFeedPaper(int value)

Remarks:The maximum paper distance is 1016mm (40 inches), if this distance is exceeded, the maximum distance is taken

parameter:

  1. value –> height(0-255).

1
IminPrintUtils.getInstance(TestPrintActivity.this).printAndFeedPaper(100);

5、 Cutter (paper cutting) correlation

Function:void partialCut()

Remarks:equipment support is required

1
IminPrintUtils.getInstance(TestPrintActivity.this).partialCut();

6、Set text alignment

Function:void setAlignment(int alignment)

parameter:

  1. alignment –> Set text alignment 0 = left / 1 = center / 2 = right / default = 0

1
IminPrintUtils.getInstance(TestPrintActivity.this).setAlignment(1);

7、Set text size

Function:void setTextSize(int size)

parameter:

  1. size –> Set text size default 28

1
IminPrintUtils.getInstance(TestPrintActivity.this).setTextSize(26);

8、Set font

Function:void setTextTypeface(Typeface typeface)

parameter:

  1. typeface –> Set font default Typeface.DEFAULT

1
IminPrintUtils.getInstance(TestPrintActivity.this).setTextTypeface(Typeface.DEFAULT);

9、Set font style

Function:void setTextStyle(int style)

parameter:

  1. style –> Set the font style (bold or italic) NORMAL = 0 BOLD = 1 ITALIC = 2 BOLD_ITALIC = 3

1
IminPrintUtils.getInstance(TestPrintActivity.this).setTextStyle(1);

10、Set line spacing

Function:void setTextLineSpacing(float space)

parameter:

  1. space –> Set line spacing default 1.0f

1
IminPrintUtils.getInstance(TestPrintActivity.this).setTextLineSpacing(1.0f);

11、Set print width

Function:void setTextWidth(int width)

parameter:

  1. width –> Default 80mm printer default effective print width 576

1
IminPrintUtils.getInstance(TestPrintActivity.this).setTextWidth(576);

12、Print text

Function:void printText(String text)

parameter:

  1. text –> Print content; will automatically wrap

1
IminPrintUtils.getInstance(TestPrintActivity.this).printText("打印内容");

13、Print text

Function:void printText(String text, int type)

parameter:

  1. text –> When the printed content is less than one or more lines, you need to add a line break “n” at the end of the content to print it immediately, otherwise it will be cached in the buffer.

  2. type –> Default value 0;

    0 = you need to add a line break “n” at the end of the content to print it immediately, otherwise it will be cached in the buffer.

    1 = Word wrap

Note: to change the style of the printed text (such as alignment, font size, bold, etc.),set it before calling the printText method.

1
IminPrintUtils.getInstance(TestPrintActivity.this).printText("打印内容", 0);

14、Print a row of the table (not support Arabic)

Function:void printColumnsText(String[] colTextArr, int[] colWidthArr, int[] colAlign, int width, int[] size)

parameter:

  1. colTextArr –> column text string array

  2. colWidthArr –> Array of the width of each column, calculated in English characters, each Chinese character occupies two English characters, each width is greater than 0.

  3. colAlign –> alignment: 0 to the left, 1 to the center, and 2 to the right

  4. size –> Font size per column string array

  5. width –> Print the total width of a line (80mm printing paper = 576)

1
IminPrintUtils.getInstance(TestPrintActivity.this).printColumnsText(new String[]{"1","iMin","iMin"} ,new String[]{1,2,1} ,new String[]{1,0,2} ,new String[]{26,26,26} ,576);

15、Set barcode width

Function:void setBarCodeWidth(int width)

parameter:

  1. width –> barcode width level 2 <= width <= 6 If you do not set the default barcode width level to 3

1
IminPrintUtils.getInstance(TestPrintActivity.this).setBarCodeWidth(4);

16、Set the height of the barcode

Function:void setBarCodeHeight(int height)

parameter:

  1. height –> barcode height 1 <= height <= 255 Same as above, every 8 points is 1mm

1
IminPrintUtils.getInstance(TestPrintActivity.this).setBarCodeHeight(100);

17、When printing barcodes, select the printing position for HRI characters

Function:void setBarCodeContentPrintPos(int position)

parameter:

  1. position –> position HRI character printing position

    0 –> Do not print

    1 –> Above the barcode

    2 –> Below the barcode

    3 –> Barcodes are printed above and below

1
IminPrintUtils.getInstance(TestPrintActivity.this).setBarCodeContentPrintPos(2);

18、Print barcode

Function:void printBarCode(int barCodeType, String barCodeContent) throws UnsupportedEncodingException

parameter:

  1. barCodeType –> barcode type 0 <= barcodeType <= 6

  2. barCodeContent –> Printed barcode character content

note:

barcodeType value   Supported barcode content length                    Supported ASCII code range
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,                       48≤range≤57,65≤range≤90,range = 32, 36, 37, 42, 43, 45, 46, 47
5 --> ITF              barCodeContent.length >=2                                48 ≤range≤ 57
6 --> CODABAR          barCodeContent.length >=2,                       48≤range≤57, 65≤range≤68,97≤range≤100,range = 36, 43, 45, 46, 47, 58
1
IminPrintUtils.getInstance(TestPrintActivity.this).printBarCode(2 ,"0123456789");

19、Print barcode

Function:void printBarCode(int barCodeType, String barCodeContent, int alignmentMode) throws UnsupportedEncodingException

parameter:

  1. barCodeType –> barcode type 0 <= barcodeType <= 6

  2. barCodeContent –> Printed barcode character content

  3. alignmentMode –> 0 = Left / 1 = Center / 2 = Right

note:

barcodeType value   Supported barcode content length                    Supported ASCII code range
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,                       48≤range≤57,65≤range≤90,range = 32, 36, 37, 42, 43, 45, 46, 47
5 --> ITF              barCodeContent.length >=2                                48 ≤range≤ 57
6 --> CODABAR          barCodeContent.length >=2,                       48≤range≤57, 65≤range≤68,97≤range≤100,range = 36, 43, 45, 46, 47, 58
1
IminPrintUtils.getInstance(TestPrintActivity.this).printBarCode(2 ,"0123456789", 1);

20、Set the size of the QR code

Function:void setQrCodeSize(int level)

parameter:

  1. level –> QR code block size, unit: dot, 1 <= level <= 16

1
IminPrintUtils.getInstance(TestPrintActivity.this).setQrCodeSize(2);

21、Set QR code error correction

Function:void setQrCodeErrorCorrectionLev(int level)

parameter:

  1. level –> level >= 48 && level <= 51

1
IminPrintUtils.getInstance(TestPrintActivity.this).setQrCodeErrorCorrectionLev(51);

22、Set left margin of barcode and QR code

Function:void setLeftMargin(int marginValue)

parameter:

  1. marginValue –> Left Spacing Value 0-576

1
IminPrintUtils.getInstance(TestPrintActivity.this).setLeftMargin(100);

23、Printer QR code

Function:void printQrCode(String qrStr)

parameter:

  1. qrStr –> QR code content.

1
IminPrintUtils.getInstance(TestPrintActivity.this).printQrCode("https://www.imin.sg");

24、Printer QR code

Function:void printQrCode(String qrStr, int alignmentMode)

parameter:

  1. qrStr –> QR code content.

  2. alignmentMode –> 0 = Left / 1 = Center / 2 = Right.

1
IminPrintUtils.getInstance(TestPrintActivity.this).printQrCode("https://www.imin.sg", 1);

25、Set paper specifications

Function:void setPageFormat(int style)

parameter:

  1. style –> 0-80mm 1-58mm

1
IminPrintUtils.getInstance(TestPrintActivity.this).setPageFormat(1);

26、Print bitmap

Function:void printSingleBitmap(Bitmap bitmap)

parameter:

  1. bitmap –> bitmap

1
IminPrintUtils.getInstance(TestPrintActivity.this).printSingleBitmap(bitmap);

27、Print bitmap

Function:void printSingleBitmap(Bitmap bitmap, int alignmentMode)

parameter:

  1. bitmap –> Bitmap

  2. alignmentMode –> 0 = Left / 1 = Center / 2 = Right.

1
IminPrintUtils.getInstance(TestPrintActivity.this).printSingleBitmap(bitmap, 1);

28、Print multiple bitmaps

Function:void printMultiBitmap(List<Bitmap> bitmaps)

parameter:

  1. bitmap –> bitmaps

1
IminPrintUtils.getInstance(TestPrintActivity.this).printMultiBitmap(bitmaps);

29、Print multiple bitmaps

Function:void printMultiBitmap(List<Bitmap> bitmaps, int alignmentMode)

parameter:

  1. bitmap –> bitmaps

  2. alignmentMode –> 0 = Left / 1 = Center / 2 = Right.

1
IminPrintUtils.getInstance(TestPrintActivity.this).printMultiBitmap(bitmaps, 1);

2.Use the built-in virtual blueprint to call the printer

Introduction to Virtual Blue

In the bluetooth device list, you can see a paired and always-existing bluetooth device “BluetoothPrinter”, which is a printer device virtualized by the operating system and does not actually exist. Some of these special commands are iMin self-defined commands, such as:

Use of Virtual Blue

  1. Establish a connection with the Bluetooth device.

  2. Splice the instructions and text into Bytes.

  3. Send to BluetoothPrinter.

  4. The underlying printing service drives the printing device to complete printing.