1.0.2 • Published 3 years ago

cordova-plugin-iposprinter v1.0.2

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
3 years ago

Cordova Plugin for IPosPrinter Service

npm version npm downloads

Install

Cordova

$ cordova plugin add cordova-plugin-iposprinter

Ionic

$ ionic cordova plugin add cordova-plugin-iposprinter

Capacitor

$ npm install cordova-plugin-iposprinter
$ npx cap sync

Functions

getPrinterStatus()

Printer status query

printerInit()

Printer initialization Power on the printer and initialize the default settings Please check the printer status when using, please wait when PRINTER_IS_BUSY

setPrinterPrintDepth(depth)

Set the print density of the printer, which will affect subsequent printing, unless initialized

ParamTypeDescription
depthnumberConcentration level, range 1-10, this function will not be executed if the range is exceeded Default level 6

setPrinterPrintFontType(typeface)

Set the print font type, which will affect subsequent printing, unless initialized (Currently only one font ST is supported, more font support will be provided in the future)

ParamTypeDescription
typefacestringFont name ST

setPrinterPrintFontSize(fontsize)

Set the font size, which will affect subsequent printing, unless initialized Note: The font size is a printing method that exceeds the standard international directives. Adjusting the font size will affect the character width, and the number of characters per line will also change accordingly. Therefore, the typesetting formed in monospaced fonts may be messy and needs to be adjusted by yourself

ParamTypeDescription
fontsizenumberFont size, currently supported sizes are 16, 24, 32, 48, input illegal size executes the default value 24

setPrinterPrintAlignment(alignment)

Set the alignment, which will affect subsequent printing, unless initialized

ParamTypeDescription
alignmentnumberAlignment 0: Left, 1: Center, 2: Right, Center by default

printerFeedLines(lines)

Printer paper feed (forced line feed, paper feed lines after finishing the previous printing content, at this time the motor runs idling to feed paper, no data is sent to the printer)

ParamTypeDescription
linesnumberThe number of printer paper lines (each line is a pixel)

printBlankLines(lines, height)

Print blank lines (Forced to wrap, print blank lines after finishing the previous print content, the data sent to the printer at this time are all 0x00)

ParamTypeDefaultDescription
linesnumberPrint the number of blank lines, limit up to 100 lines
heightnumber1The height of the blank line (unit: pixel)

printText(text)

Print text The text width is full of one line and automatically wrap and typesetting

ParamTypeDescription
textstringText string to be printed

printSpecifiedTypeText(text, typeface, fontsize)

Print the specified font type and size text, the font setting is only valid for this time The text width is full of one line and automatically wrap

ParamTypeDefaultDescription
textstringText string to be printed
typefacestring"ST"Font name ST (currently only supports one type)
fontsizenumber24Font size, currently supported sizes are 16, 24, 32, 48, input illegal size executes the default value 24

printSpecFormatText(text, typeface, fontsize, alignment)

Print the specified font type and size text, the font setting is only valid for this time The text width is full of one line and automatically wrap and typesetting

ParamTypeDefaultDescription
textstringText string to be printed
typefacestring"ST"Font name ST (currently only supports one type)
fontsizenumber24Font size, currently supported sizes are 16, 24, 32, 48, input illegal size executes the default value 24
alignmentnumber0Alignment (0 to the left, 1 to the center, 2 to the right)

printColumnsText(colsTextArr, colsWidthArr, colsAlign, isContinuousPrint)

Print a row of the table, you can specify the column width and alignment

ParamTypeDescription
colsTextArrArray.<string>Array of text strings for each column
colsWidthArrArray.<number>The total width of each column width array cannot be greater than ((384 / fontsize) << 1)-(number of columns + 1) (Calculated in English characters, each Chinese character occupies two English characters, and each width is greater than 0),
colsAlignArray.<number>Alignment of each column (0 to the left, 1 to the center, 2 to the right)
isContinuousPrintArray.<number>Whether to continue printing the form 1: Continue printing 0: Do not continue printing Remarks: The length of the array of the three parameters should be the same, if the width of colsTextArri is greater than colsWidthArri, the text will wrap

printBitmap(alignment, bitmapSize, mBitmap)

Print picture

ParamTypeDefaultDescription
alignmentnumber1Alignment 0: Left, 1: Center, 2: Right, Center by default
bitmapSizenumber10Bitmap size, the input size range is 1~16, 10 is selected by default when the range is exceeded Unit: 24bit
mBitmapArray.<number> | Array.<string>Picture bitmap object (maximum width 384 pixels, unable to print and call back abnormal callback function)

printBarCode(data:, symbology, height, width, textposition)

Print one-dimensional barcode

ParamTypeDescription
data:stringBarcode data
symbologynumberBarcode type 0 -- UPC-A, 1 -- UPC-E, 2 -- JAN13(EAN13), 3 -- JAN8(EAN8), 4 -- CODE39, 5 -- ITF, 6 -- CODABAR, 7 -- CODE93, 8 -- CODE128
heightnumberBar code height, the value ranges from 1 to 16, the default value is 6 if it exceeds the range, each unit represents the height of 24 pixels
widthnumberBarcode width, the value ranges from 1 to 16, the default value is 12 if it exceeds the range, each unit represents the length of 24 pixels
textpositionnumberText position 0: Do not print the text, 1: The text is above the bar code, 2: The text is below the bar code, 3: Both the top and bottom of the bar code are printed

printQRCode(data, modulesize, mErrorCorrectionLevel:)

Print 2D barcode

ParamTypeDefaultDescription
datastringQR code data
modulesizenumber10Two-dimensional code block size (unit: point, value 1 to 16), beyond the setting range, the default value is 10
mErrorCorrectionLevel:numberTwo-dimensional error correction level (0:L 1:M 2:Q 3:H)

printRawData(rawPrintData)

Print raw byte data

ParamTypeDescription
rawPrintDataArray.<string> | Array.<number>Byte Data block

sendUserCMDData(data)

Use ESC/POS command to print

ParamTypeDescription
dataArray.<string> | Array.<number>Instructions

printerPerformPrint(feedlines)

Perform printing After executing each printing function method, you need to execute this method before the printer can execute printing; Before executing this method, it is necessary to determine the status of the printer. This method is valid when the printer is in PRINTER_NORMAL, otherwise it will not be executed.

ParamTypeDefaultDescription
feedlinesnumber150Print and feed paper feed