JSPrinterSDK

1.Call the printer via SDK

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

Print Demo source code

1、Printer initialization

Function: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.

1IminPrintInstance.initPrinter(IminPrintInstance.PrintConnectType.SPI);

parameter:

IminPrintInstance.PrintConnectType.USB –> USB

IminPrintInstance.PrintConnectType.SPI –> SPI

IminPrintInstance.PrintConnectType.Bluetooth –> Bluetooth

2、Get printer status

Function : getPrinterStatus(IminPrintInstance.PrintConnectType, callback)

return value:

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

1 –> The printer is not connected or powered on

3 –> Print head open

7 –> No Paper Feed

8 –> Paper Running Out

99 –> Other errors

1IminPrintInstance.getPrinterStatus(IminPrintInstance.PrintConnectType.SPI, function (status) {
2   console.log('printer status:' + status.value);
3})

3、Print and feed paper

Function:printAndLineFeed()

Remarks:The printer runs on 1 lines of paper

1IminPrintInstance.printAndLineFeed();

4、Print blank lines (custom height)

Function: printAndFeedPaper(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).

1IminPrintInstance.printAndFeedPaper(100);

5、 Cutter (paper cutting) correlation

Function:partialCut()

Remarks:equipment support is required

1IminPrintInstance.partialCut();

6、Set text alignment

Function: setAlignment(alignment)

parameter:

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

1IminPrintInstance.setAlignment(1);

7、Set text size

Function: setTextSize(size)

parameter:

  1. size –> Set text size default 28

1IminPrintInstance.setTextSize(26);

8、Set font

Function:setTextTypeface(typeface)

parameter:

  1. typeface –> Set font DEFAULT = 0 MONOSPACE = 1 DEFAULT_BOLD = 2 SANS_SERIF = 3 SERIF = 4

1IminPrintInstance.setTextTypeface(0)

9、Set font style

Function:setTextStyle(style)

parameter:

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

1IminPrintInstance.setTextStyle(1);

10、Set line spacing

Function:setTextLineSpacing(space)

parameter:

  1. space –> Set line spacing default 1.0f

1IminPrintInstance.setTextLineSpacing(1.0f);

11、Set print width

Function: setTextWidth(width)

parameter:

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

1IminPrintInstance.setTextWidth(576);

12、Print text

Function: printText(text)

parameter:

  1. text –> Print content; will automatically wrap

1IminPrintInstance.printText('test print centent');

13、Print text

Function:printText(text, 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.

1IminPrintInstance.printText('test print centent',0);

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

Function:printColumnsText(colTextArr, colWidthArr, colAlign, width, 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)

1IminPrintInstance.printColumnsText(["1","iMin","iMin"],[1,2,1],[1,0,2],[26,26,26],576);

15、Set barcode width

Function:setBarCodeWidth(int width)

parameter:

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

1IminPrintInstance.setBarCodeWidth(4);

16、Set the height of the barcode

Function:setBarCodeHeight(height)

parameter:

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

1IminPrintInstance.setBarCodeHeight(100);

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

Function:setBarCodeContentPrintPos(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

1IminPrintInstance.setBarCodeContentPrintPos(2);

18、Print barcode

Function:printBarCode(barCodeType, barCodeContent) throws UnsupportedEncodingException

parameter:

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

  2. barCodeContent –> Printed barcode character content, if it is code128 printing, you need to add {A ,{B or {C in front,you can see the following example

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
73 -->CODE128          barCodeContent.length >=2                                  0≤range≤127
1IminPrintInstance.printBarCode(73,"{B0123456789");

19、Print barcode

Function:printBarCode( barCodeType, barCodeContent, alignmentMode) throws UnsupportedEncodingException

parameter:

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

  2. barCodeContent –> Printed barcode character content, if it is code128 printing, you need to add {A ,{B or {C in front,you can see the following example

  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
73 --> CODE128         barCodeContent.length >=2                                  0≤range≤127
1IminPrintInstance.printBarCode(73 ,"{B0123456789", 1);

20、Set the size of the QR code

Function:setQrCodeSize(level)

parameter:

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

1IminPrintInstance.setQrCodeSize(2);

21、Set QR code error correction

Function:setQrCodeErrorCorrectionLev(level)

parameter:

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

1IminPrintInstance.setQrCodeErrorCorrectionLev(51);

22、Set left margin of barcode and QR code

Function:setLeftMargin(marginValue)

parameter:

  1. marginValue –> Left Spacing Value 0-576

1IminPrintInstance.setLeftMargin(100);

23、Printer QR code

Function:printQrCode(qrStr)

parameter:

  1. qrStr –> QR code content.

1IminPrintInstance.printQrCode("https://www.imin.sg");

24、Printer QR code

Function:printQrCode(qrStr, alignmentMode)

parameter:

  1. qrStr –> QR code content.

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

1IminPrintInstance.printQrCode("https://www.imin.sg", 1);

25、Set paper specifications

Function:setPageFormat(style)

parameter:

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

1IminPrintInstance.setPageFormat(1);

26、Print bitmap

Function:printSingleBitmap(bitmap)

parameter:

  1. imgResources ->( base64 or url)

1IminPrintInstance.printSingleBitmap("data:image/ico;base64,AAABAAEAICAAAAEAIACoEAAAFgAAACgAAAAgAAAAQAAAAAEAIAAAAAAAABAAAAAAAAAAAAAAAAAAA...");
2IminPrintInstance.printSingleBitmap('https://t7.baidu.com/it/u=1517419723,1472324058&fm=193&f=GIF')

27、openCashBox

Function:openCashBox()

1IminPrintInstance.openCashBox();

28、setDoubleQRSize

Function:setDoubleQRSize(size)

parameter:

  1. size –> 1<= size <= 8

  2. Note: The setDoubleQRSize method only supports models M2-203, M2 Pro, M2 Max, and D1

1IminPrintInstance.setDoubleQRSize(1)

29、setDoubleQR1Level

Function:setDoubleQR1Level(level)

parameter:

  1. level –> 0-3

  1. Note: The setDoubleQR1Level method only supports models M2-203, M2 Pro, M2 Max, and D1

1IminPrintInstance.setDoubleQR1Level(16)

30、setDoubleQR2Level

Function:setDoubleQR2Level(level)

parameter:
  1. level –> 0-3

  2. Note: The setDoubleQR2Level method only supports models M2-203, M2 Pro, M2 Max, and D1

1IminPrintInstance.setDoubleQR2Level(16)

31、setDoubleQR1MarginLeft

Function:setDoubleQR1MarginLeft(marginValue)

parameter:
  1. marginValue –> Left Spacing Value 0-576

  2. Note: The setDoubleQR1MarginLeft method only supports models M2-203, M2 Pro, M2 Max, and D1

1IminPrintInstance.setDoubleQR1MarginLeft(26)

32、setDoubleQR2MarginLeft

Function:setDoubleQR2MarginLeft(marginValue)

parameter:
  1. marginValue –> Left Spacing Value 0-576

  2. Note: The setDoubleQR2MarginLeft method only supports models M2-203, M2 Pro, M2 Max, and D1

1IminPrintInstance.setDoubleQR2MarginLeft(26)

33、setDoubleQR1Version

Function:setDoubleQR1Version(version)

parameter:
  1. version -> 0-40

  2. Note: The setDoubleQR1Version method only supports models M2-203, M2 Pro, M2 Max, and D1

1IminPrintInstance.setDoubleQR1Version(40)

34、setDoubleQR2Version

Function:setDoubleQR2Version(version)

parameter:
  1. version -> 0-40

  2. Note: The setDoubleQR2Version method only supports models M2-203, M2 Pro, M2 Max, and D1

1IminPrintInstance.setDoubleQR2Version(40)

34、printDoubleQR

Function:printDoubleQR(colTextArr)

parameter:
  1. colTextArr –> column text string array

  2. Note: The printDoubleQR method only supports models M2-203, M2 Pro, M2 Max, and D1

1IminPrintInstance.printDoubleQR(["www.iMin.sg", "www.google.com"]);