2.1.0 • Published 9 months ago

capacitor-ble-printer2 v2.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

capacitor-ble-printer2

Capacitor plugin for Zebra printers with Bluetooth.

Install

npm install capacitor-ble-printer2
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"/>
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>
<uses-permission android:name="android.permission.BLUETOOTH_SCAN"/>

Usage

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!")
}

API

print(...)

print(options: PrinterOptions) => Promise<any>

You can send data in ZPL Zebra Programing Language

ParamType
optionsPrinterOptions

Returns: Promise<any>


listenPrinters()

listenPrinters() => Promise<{ devices: BluetoothDevices[]; }>

Discover bonded devices

Returns: Promise<{ devices: BluetoothDevices[]; }>


openBluetoothSettings()

openBluetoothSettings() => Promise<any>

Show the Bluetooth settings on the device

Returns: Promise<any>


enableBluetooth()

enableBluetooth() => Promise<any>

Enable Bluetooth on the device

Returns: Promise<any>


getStatusPrinter(...)

getStatusPrinter(options: StatusPrinterOptions) => Promise<{ status: string; }>

You can get a status response from a connected Zebra printer using

ParamType
optionsStatusPrinterOptions

Returns: Promise<{ status: string; }>


getZPLFromImage(...)

getZPLFromImage(options: ZPLConverterOptions) => Promise<{ zplCode: string; }>

Get ZPL equivalent code from the base64 Image string

ParamType
optionsZPLConverterOptions

Returns: Promise<{ zplCode: string; }>


Interfaces

PrinterOptions

PropTypeDescription
macAddressstringIdentifier of the remote device
printTextstringtext to print

BluetoothDevices

PropTypeDescription
namestringName of the remote device
macAddressstringIdentifier of the remote device
idstring
classstring

StatusPrinterOptions

PropTypeDescription
macAddressstringIdentifier of the remote device

ZPLConverterOptions

PropTypeDescription
base64Imagestringbase64 Image string
blacknessPercentagenumberWant to add header/footer ZPL code or not
addHeaderFooterbooleanWant to add header/footer ZPL code or not
2.1.0

9 months ago

2.0.5

1 year ago

2.0.6

1 year ago

2.0.4

1 year ago

2.0.3

1 year ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago