1.0.1 • Published 4 years ago
capacitor-ble-printer v1.0.1
capacitor-ble-printer
Capacitor plugin for Zebra printers with Bluetooth.
Install
npm install capacitor-ble-printer
npx cap sync
Android
Add the following to your AndroidManifest.xml
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
Usage
You can send data in ZPL Zebra
import { ZPLPrinter } from 'capacitor-ble-printer'
//Bounded Devices
ZPLPrinter.listenPrinters().then(value => {
console.log(value.devices);
});
//Print Text
var printText = "^XA"
+ "^FO20,20^A0N,25,25^FDThis is a ZPL test.^FS"
+ "^XZ";
var printerOpts: PrinterOptions = {
macAddress: macAddressPrinter,
printText: printText
}
ZPLPrinter.print(printerOpts).then(_ => {
console.log("Printer Ok!")
}
API
print(...)
listenPrinters()
openBluetoothSettings()
enableBluetooth()
getStatusPrinter(...)
getZPLFromImage(...)
- Interfaces
print(...)
print(options: PrinterOptions) => any
You can send data in ZPL Zebra Programing Language
Param | Type |
---|---|
options | PrinterOptions |
Returns: any
listenPrinters()
listenPrinters() => any
Discover bonded devices
Returns: any
openBluetoothSettings()
openBluetoothSettings() => any
Show the Bluetooth settings on the device
Returns: any
enableBluetooth()
enableBluetooth() => any
Enable Bluetooth on the device
Returns: any
getStatusPrinter(...)
getStatusPrinter(options: StatusPrinterOptions) => any
You can get a status response from a connected Zebra printer using
Param | Type |
---|---|
options | StatusPrinterOptions |
Returns: any
getZPLFromImage(...)
getZPLFromImage(options: ZPLConverterOptions) => any
Get ZPL equivalent code from the base64 Image string
Param | Type |
---|---|
options | ZPLConverterOptions |
Returns: any
Interfaces
PrinterOptions
Prop | Type | Description |
---|---|---|
macAddress | string | Identifier of the remote device |
printText | string | text to print |
BluetoothDevices
Prop | Type | Description |
---|---|---|
name | string | Name of the remote device |
macAddress | string | Identifier of the remote device |
id | string | |
class | string |
StatusPrinterOptions
Prop | Type | Description |
---|---|---|
macAddress | string | Identifier of the remote device |
ZPLConverterOptions
Prop | Type | Description |
---|---|---|
base64Image | string | base64 Image string |
blacknessPercentage | number | Want to add header/footer ZPL code or not |
addHeaderFooter | boolean | Want to add header/footer ZPL code or not |