Capacitor plugin for Zebra printers with Bluetooth.
npm install capacitor-ble-printer2
npx cap sync
Add the following to your AndroidManifest.xml
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>
<uses-permission android:name="android.permission.BLUETOOTH_SCAN"/>
You can send data in ZPL Zebra
import { ZPLPrinter } from 'capacitor-ble-printer2'
//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!")
}
print(...)
listenPrinters()
openBluetoothSettings()
enableBluetooth()
getStatusPrinter(...)
getZPLFromImage(...)
- Interfaces
print(options: PrinterOptions) => Promise<any>
You can send data in ZPL Zebra Programing Language
Param | Type |
---|---|
options |
PrinterOptions |
Returns: Promise<any>
listenPrinters() => Promise<{ devices: BluetoothDevices[]; }>
Discover bonded devices
Returns: Promise<{ devices: BluetoothDevices[]; }>
openBluetoothSettings() => Promise<any>
Show the Bluetooth settings on the device
Returns: Promise<any>
enableBluetooth() => Promise<any>
Enable Bluetooth on the device
Returns: Promise<any>
getStatusPrinter(options: StatusPrinterOptions) => Promise<{ status: string; }>
You can get a status response from a connected Zebra printer using
Param | Type |
---|---|
options |
StatusPrinterOptions |
Returns: Promise<{ status: string; }>
getZPLFromImage(options: ZPLConverterOptions) => Promise<{ zplCode: string; }>
Get ZPL equivalent code from the base64 Image string
Param | Type |
---|---|
options |
ZPLConverterOptions |
Returns: Promise<{ zplCode: string; }>
Prop | Type | Description |
---|---|---|
macAddress |
string |
Identifier of the remote device |
printText |
string |
text to print |
Prop | Type | Description |
---|---|---|
name |
string |
Name of the remote device |
macAddress |
string |
Identifier of the remote device |
id |
string |
|
class |
string |
Prop | Type | Description |
---|---|---|
macAddress |
string |
Identifier of the remote device |
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 |