Skip to content

ticketplushq/capacitor-pos-pax-printer-utility

Repository files navigation

@ticketplushq/capacitor-pos-pax-printer-utility

Printer integration for PAX payment POS, Android support.

In web context it behaves like a mock that returns successful execution results.

When executed in the emulator or on a device other than the POS, it will generate an error that will stop the application. This is due to the lack of installation of the NeptuneService app. At the moment, it has not been possible to install NeptuneService on a device other than POS but work is being done to achieve it.

Permissions

Adding permissions in the AndroidManifest.xml file

<uses-permission android:name="com.pax.permission.PRINTER"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

Install

npm install @ticketplushq/capacitor-pos-pax-printer-utility
npx cap sync

API

init()

init() => Promise<{ ok: boolean; }>

Get printer and init instance

Returns: Promise<{ ok: boolean; }>


start()

start() => Promise<StatusResp>

Run printer commands

Returns: Promise<StatusResp>


printStr(...)

printStr({ text }: PrintStrArgs) => Promise<void>

Print text string

Param Type Description
__0 PrintStrArgs <{text: string, charset: string}>

printBase64Image(...)

printBase64Image({ image }: PrintBase64ImageArgs) => Promise<StatusResp>

Print base64 image (jpg) (in development)

Param Type Description
__0 PrintBase64ImageArgs <{image: string}>

Returns: Promise<StatusResp>


printReceipt(...)

printReceipt({ text }: PrintReceiptArgs) => Promise<StatusResp>

Print receipt only

Param Type Description
__0 PrintReceiptArgs <{text: string, asciiFontType?:EFontTypeAscii, cFontType?: EFontTypeExtCode}>

Returns: Promise<StatusResp>


printReceiptWithQr(...)

printReceiptWithQr({ text, qrString, }: PrintReceiptWithQrArgs) => Promise<StatusResp>

Print receipt and QR code content

Param Type Description
__0 PrintReceiptWithQrArgs <{text: string, qrString: string, asciiFontType?:EFontTypeAscii, cFontType?: EFontTypeExtCode}>

Returns: Promise<StatusResp>


printQR(...)

printQR({ text, qrString, startText, endText, }: PrintQrArgs) => Promise<StatusResp>

Print QR code content, optionally you can pass a text to print before (startText) and after (endText) the QR code, the content of the text argument is printed before startText and with the size of endText

Param Type Description
__0 PrintQrArgs <{text: string, qrString: string, startText?:string, endText?: string, asciiFontType?:EFontTypeAscii, cFontType?: EFontTypeExtCode}>

Returns: Promise<StatusResp>


cutPaper(...)

cutPaper({ mode }: CutPaperMode) => Promise<{ ok: boolean; }>

Set printer cut mode, remember that to use this method you must before started the printer instance,

Param Type Description
__0 CutPaperMode <{mode: number}>

Returns: Promise<{ ok: boolean; }>


getCutMode()

getCutMode() => Promise<CutPaperMode>

Get printer cut mode, remember that to use this method you must before started the printer instance,

Returns: Promise<CutPaperMode>


getStatus()

getStatus() => Promise<StatusResp>

Get printer status, remember that to use this method you must before started the printer instance,

Returns: Promise<StatusResp>


fontSet(...)

fontSet(asciiFontType: EFontTypeAscii, cFontType: EFontTypeExtCode) => Promise<void>

Set print font

Param Type Description
asciiFontType EFontTypeAscii EFontTypeAscii
cFontType EFontTypeExtCode EFontTypeExtCode

doubleHeight(...)

doubleHeight(isAscDouble: boolean, isLocalDouble: boolean) => Promise<void>

Set printing font which is based on base font to double height.

Param Type Description
isAscDouble boolean If the single coding font is double height or not.
isLocalDouble boolean If the multi coding font is double height or not.

doubleWidth(...)

doubleWidth(isAscDouble: boolean, isLocalDouble: boolean) => Promise<void>

Set printing font which is based on base font to double width.

Param Type Description
isAscDouble boolean If the single coding font is double width or not.
isLocalDouble boolean If the multi coding font is double width or not.

Interfaces

StatusResp

Prop Type
status StatusCodes

PrintStrArgs

Prop Type
text string

PrintBase64ImageArgs

Prop Type
image string

PrintReceiptArgs

Prop Type
text string

PrintReceiptWithQrArgs

Prop Type
text string
qrString string | null

PrintQrArgs

Prop Type
text string | null
qrString string | null
startText string | null
endText string | null
asciiFontTypeEnd EFontTypeAscii | null
cFontTypeEnd EFontTypeExtCode | null

CutPaperMode

Prop Type
mode CutMode

Type Aliases

StatusCodes

Value Description
0 Success
1 Printer is busy
2 Out of paper
3 The format of print data packet error
4 Printer malfunctions
8 Printer over heats
9 Printer voltage is too low
-16 Printing is unfinished
-6 cut jam error(only support:E500,E800)
-5 cover open error(only support:E500,E800,SK600,SK800)
-4 The printer has not installed font library
-2 Data package is too long

0 | 1 | 2 | 3 | 4 | 8 | 9 | -16 | -6 | -5 | -4 | -2

CutMode

Value Description
0 FULL_PAPER_CUTTING
1 PARTIAL_PAPER_CUTTING
2 FULL_AND_PARTIAL_PAPER_CUTTING
-1 NO_CUTTING_KNIFE_NOT_SUPPORTED

0 | 1 | 2 | -1

Enums

EFontTypeAscii

Members Value Description
FONT_8_16 'FONT_8_16' 8x16 font (Basic)
FONT_12_24 'FONT_12_24' 12x24 font (Basic)
FONT_8_32 'FONT_8_32' 8x16 font (enlarge vertically)
FONT_12_48 'FONT_12_48' 12x24 font (enlarge vertically)
FONT_16_16 'FONT_16_16' 8x16 font (enlarge horizontally)
FONT_24_24 'FONT_24_24' 12x24 font (enlarge horizontally)
FONT_16_32 'FONT_16_32' 8x16 font (enlarge on both levels)
FONT_24_48 'FONT_24_48' 12x24 font (enlarge on both levels)

EFontTypeExtCode

Members Value Description
FONT_16_16 'FONT_16_16' 16x16 font (Basic)
FONT_24_24 'FONT_24_24' 24x24 font (Basic)
FONT_16_32 'FONT_16_32' 16x16 font (enlarge vertically)
FONT_24_48 'FONT_24_48' 24x24 font (enlarge vertically)
FONT_32_16 'FONT_32_16' 16x16 font (enlarge horizontally)
FONT_48_24 'FONT_48_24' 24x24 font (enlarge horizontally)
FONT_32_32 'FONT_32_32' 16x16 font (enlarge on both levels)
FONT_48_48 'FONT_48_48' 24x24 font (enlarge on both levels)