capacitor-plugin-escpos-usb-printer
v8.1.0
Published
Capacitor Plugin for printing to epson usb printer
Readme
capacitor-plugin-escpos-usb-printer
Capacitor Plugin for printing to ESC/POS (Epson-compatible) USB printers.
Fork of whimsicaldev/capacitor-plugin-epson-usb-printer, maintained at sandyclock/capacitor-plugin-escpos-usb-printer.
Install
npm install capacitor-plugin-escpos-usb-printer
npx cap syncAPI
getPrinterList()hasPermission(...)retrieveSerial(...)connectToPrinter(...)printHexArray(...)print(...)sendAndReceive(...)- Interfaces
getPrinterList()
getPrinterList() => Promise<{ printerList: EpsonUSBPrinterInfo[]; }>Returns: Promise<{ printerList: EpsonUSBPrinterInfo[]; }>
hasPermission(...)
hasPermission(options: { deviceId: number; }) => Promise<{ permission: boolean; }>| Param | Type |
| ------------- | ---------------------------------- |
| options | { deviceId: number; } |
Returns: Promise<{ permission: boolean; }>
retrieveSerial(...)
retrieveSerial(options: { deviceId: number; }) => Promise<{ serial: string; }>| Param | Type |
| ------------- | ---------------------------------- |
| options | { deviceId: number; } |
Returns: Promise<{ serial: string; }>
connectToPrinter(...)
connectToPrinter(options: { deviceId: number; vendorId: number; productId: number; }) => Promise<{ connected: boolean; }>| Param | Type |
| ------------- | ----------------------------------------------------------------------- |
| options | { deviceId: number; vendorId: number; productId: number; } |
Returns: Promise<{ connected: boolean; }>
printHexArray(...)
printHexArray(options: { content: string; }) => Promise<void>| Param | Type |
| ------------- | --------------------------------- |
| options | { content: string; } |
print(...)
print(options: { printObject: string; lineFeed?: number; }) => Promise<void>| Param | Type |
| ------------- | -------------------------------------------------------- |
| options | { printObject: string; lineFeed?: number; } |
sendAndReceive(...)
sendAndReceive(options: { command: string; terminator?: string; idle?: number; timeout?: number; }) => Promise<{ value: string; bytes: number; }>Write a command to the printer and return whatever it sends back.
Values are HEX strings (e.g. "1b40", ESC @ = initialise), matching the Bluetooth plugin's convention. Note printHexArray() above takes base64 despite its name.
Completion, in order of precedence:
terminator- resolve as soon as the reply ends with these bytes;idle- resolve once data has arrived and then stopped for this long (default 600ms);timeout- hard ceiling for the whole exchange (default 8000ms).
Rejects if the device exposes no bulk IN endpoint (a print-only printer cannot reply). The command, terminator and interpretation of the reply belong to the caller: this plugin carries no vendor-specific command knowledge.
| Param | Type |
| ------------- | --------------------------------------------------------------------------------------- |
| options | { command: string; terminator?: string; idle?: number; timeout?: number; } |
Returns: Promise<{ value: string; bytes: number; }>
Interfaces
EpsonUSBPrinterInfo
| Prop | Type |
| ----------------- | -------------------- |
| productId | number |
| vendorId | number |
| productName | string |
| connected | boolean |
| deviceId | number |
