@aigens/aigens-sdk-sunmi-printer
TypeScript icon, indicating that this package has built-in type declarations

0.4.3 • Public • Published

@aigens/aigens-sdk-sunmi-printer

Aigens Order.Place Core Plugin

Install

npm install @aigens/aigens-sdk-sunmi-printer
npx cap sync

API

initPrinter()

initPrinter() => Promise<{ result: boolean; }>

Returns: Promise<{ result: boolean; }>


getStatus()

getStatus() => Promise<PrinterStatus>

Returns: Promise<PrinterStatus>


clearAllPreferenceImages()

clearAllPreferenceImages() => Promise<any>

Returns: Promise<any>


removeImageFromPreference(...)

removeImageFromPreference(options: { url: string; }) => Promise<any>
Param Type
options { url: string; }

Returns: Promise<any>


print(...)

print(options: { contents: [PrintContent]; }) => Promise<any>
Param Type
options { contents: [PrintContent]; }

Returns: Promise<any>


sendEscCommand(...)

sendEscCommand(options: { content: string; isHexString: boolean; }) => Promise<any>
Param Type
options { content: string; isHexString: boolean; }

Returns: Promise<any>


sendTsplCommand(...)

sendTsplCommand(options: { content: string; isHexString: boolean; }) => Promise<any>
Param Type
options { content: string; isHexString: boolean; }

Returns: Promise<any>


addListener('sendBroadCastReceiver', ...)

addListener(eventName: 'sendBroadCastReceiver', listenerFunc: (res: { action: string; }) => void) => Promise<PluginListenerHandle> & PluginListenerHandle
Param Type
eventName 'sendBroadCastReceiver'
listenerFunc (res: { action: string; }) => void

Returns: Promise<PluginListenerHandle> & PluginListenerHandle


addListener('scanCallbackEvent', ...)

addListener(eventName: 'scanCallbackEvent', listenerFunc: (res: { code: string; }) => void) => Promise<PluginListenerHandle> & PluginListenerHandle
Param Type
eventName 'scanCallbackEvent'
listenerFunc (res: { code: string; }) => void

Returns: Promise<PluginListenerHandle> & PluginListenerHandle


scan()

scan() => Promise<{ code: string; source: string; }>

Returns: Promise<{ code: string; source: string; }>


stopScan()

stopScan() => Promise<any>

Returns: Promise<any>


Interfaces

PrinterStatus

status = "READY" 才可以

Prop Type
status 'WARN_CARTRIDGE' | 'WARN_SPECIAL_PAPER' | 'WARN_STANDARD_PAPER' | 'WARN_PICK_PAPER' | 'WARN_THERMAL_PAPER' | 'READY' | 'OFFLINE' | 'COMM' | 'UNKNOWN' | 'ERR_PAPER_OUT' | 'ERR_PAPER_JAM' | 'ERR_PAPER_MISMATCH' | 'ERR_PRINTER_HOT' | 'ERR_MOTOR_HOT' | 'ERR_COVER' | 'ERR_COVER_INCOMPLETE' | 'ERR_CUTTER' | 'ERR_CARTRIDGE_LOSS' | 'ERR_CARTRIDGE_MISMATCH' | 'ERR_CARTRIDGE_EMPTY' | 'ERR_DUPLEX_LOSS' | 'ERR_CARTON_LOSS' | 'ERR_CARTON_MISMATCH' | 'ERR_CARTON_EMPTY' | 'ERR_DRUM_LOSS' | 'ERR_DRUM_MISMATCH' | 'ERR_DRUM_EMPTY' | 'ERR_STEP'

PrintContent

type:

    • initLine: 初始化打印机的行基础样式,这将生效于之后的每一行,重新调用方法时才改变上一次的设置; 對應: baseStyle
    • addText: 向打印机发送文本内容,addText()不会直接打印,通过多次调用addText()并设置不同的TextStyle使一行内容呈现不同效果[当最后调用addText()接口需要添加”\n”字符才可以保证打印输出]; 對應: textStyle / text
    • printText: 将直接打印出发送的文本内容; 對應: textStyle / text
    • printTexts: 向打印机按列排列发送打印内容,打印的内容为固定大小固定样式内容; 對應: texts / textStyles / colsWidthArrs
    • printBarCode: 打印一枚条形码; 對應: code / barcodeStyle
    • printQrCode: 打印一枚二维码; 對應: code / qrStyle
    • printBitmap: 打印图片; 對應: bitmapUrl / bitmapStyle
    • printDividingLine: 打印分割线; 對應: dividingLineStyle / dividingLineOffset

text:

    • 單行文字

texts:

    • 對應printTexts, 按列排列打印内容

colsWidthArrs:

    • 對應printTexts, 每一列占一行的比例大小,如 [1,1] 时将按1:1平分每列打印区域

textStyles:

    • 對應printTexts, 每列打印内容的样式设置;[为保证渲染内容准确暂时仅支持setAlign方法设置每列内容的对齐方式

baseStyle:

    • 對應initLine

barcodeStyle:

    • barcode style

qrStyle:

    • qrcode style

dividingLineStyle:

    • 分割线style; EMPTY: 空白线(即空行)/ SOLID: 实线 / DOTTED: 点线

dividingLineOffset:

    • 分割线Offset[向下移margin多少]
Prop Type
type 'initLine' | 'addText' | 'printText' | 'printTexts' | 'printBarCode' | 'printQrCode' | 'printBitmap' | 'printDividingLine'
text string
code string
texts [string]
baseStyle PrinterBaseStyle
textStyle PrinterTextStyle
textStyles [PrinterTextStyle]
colsWidthArrs [number]
barcodeStyle PrinterBarcodeStyle
qrStyle PrinterQrStyle
dividingLineStyle 'EMPTY' | 'SOLID' | 'DOTTED'
dividingLineOffset number
bitmapUrl { url: string; }
bitmapStyle printerBitmapStyle

PrinterBaseStyle

    • align:
    • "DEFAULT" , 默认居左
    • height:
    • 默认行高30像素
    • width:
    • 行内可打印区域宽度, 最大是380
    • posX:
    • 行左边距, 默认0像素
Prop Type
align 'DEFAULT' | 'LEFT' | 'CENTER' | 'RIGHT'
width number
height number
posX number

PrinterTextStyle

    • textSize:
    • 6~96, default: 24
    • textWidthRatio:
    • 0~7 , default: 0
    • textHeightRatio:
    • 0~7 , default: 0
    • textSpace:
    • 0~100 , default: 0
    • enableBold:
    • 加粗
    • enableUnderline:
    • 下划线
    • enableStrikethrough:
    • 删除线
    • enableItalics:
    • 斜体
    • enableInvert:
    • 倒置
    • enableAntiColor:
    • 反白
    • setFont:
    • 自定义字体, 设置自定义字体需要指定字体的名称,且字体需位于调用app的assets目录中供打印服务使用文本属性适用于商米打印机,第三方打印机可能不支持其中一些属性
    • align:
    • "DEFAULT" , 默认居左
Prop Type
textSize number
textWidthRatio number
textHeightRatio number
textSpace number
enableBold boolean
enableUnderline boolean
enableStrikethrough boolean
enableItalics boolean
enableInvert boolean
enableAntiColor boolean
setFont string
align 'DEFAULT' | 'LEFT' | 'CENTER' | 'RIGHT'

PrinterBarcodeStyle

    • dotWidth:
    • 码块宽度, 1~16, default: 2;
    • barHeight:
    • 条码高度, 1~255, default: 162;
    • readable:
    • 碼內容顯示的位置(比如barcode 的內容一般會顯示在下面), default: HIDE; POS_ONE: 条码上方; POS_TWO: 条码下方; POS_THREE: 条码上下;
    • symbology:
    • 条码类型: default: CODE93
    • align:
    • barcode行内对齐方式: default: center
Prop Type
dotWidth number
barHeight number
readable 'HIDE' | 'POS_ONE' | 'POS_TWO' | 'POS_THREE'
symbology 'UPCA' | 'UPCE' | 'EAN13' | 'EAN8' | 'CODE39' | 'ITF' | 'CODABAR' | 'CODE93' | 'CODE128'
align 'DEFAULT' | 'LEFT' | 'CENTER' | 'RIGHT'
width number
height number

PrinterQrStyle

    • dot:
    • 二维码块大小, 1~16; default: 4
    • errorLevel:
    • 二维码纠错等级; default: ErrorLevel.L; 纠错等级L 7% / 纠错等级M 15% / 纠错等级Q 25% / 纠错等级H 30%;
    • align:
    • 二维码行内对齐方式: default: center
Prop Type
dot number
errorLevel 'L' | 'M' | 'Q' | 'H'
align 'DEFAULT' | 'LEFT' | 'CENTER' | 'RIGHT'
width number
height number

printerBitmapStyle

    • algorithm:
    • 设置图片转换方式. BINARIZATION: 二值化算法通过调整浮动值将转换不同彩色值为黑色可根据图片颜色信息调整参数设置浮动值(默认浮动值200); DITHERING: 抖动灰度算法不用考虑浮动值变化; default 用: DITHERING
    • value:
    • 设置额外参数, 根据图片转换算法可能需要设置相应的参数
    • align:
    • 设置图片行内对齐方式
    • width:
    • 图片缩放宽度,v2s: 最大寬度是380
    • height:
    • 图片缩放高度
Prop Type
algorithm 'BINARIZATION' | 'DITHERING'
value number
align 'DEFAULT' | 'LEFT' | 'CENTER' | 'RIGHT'
width number
height number

PluginListenerHandle

Prop Type
remove () => Promise<void>

Readme

Keywords

Package Sidebar

Install

npm i @aigens/aigens-sdk-sunmi-printer

Weekly Downloads

45

Version

0.4.3

License

MIT

Unpacked Size

132 kB

Total Files

34

Last publish

Collaborators

  • aigens