1.0.1 • Published 4 years ago

capacitor-ble-printer v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

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(...)

print(options: PrinterOptions) => any

You can send data in ZPL Zebra Programing Language

ParamType
optionsPrinterOptions

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

ParamType
optionsStatusPrinterOptions

Returns: any


getZPLFromImage(...)

getZPLFromImage(options: ZPLConverterOptions) => any

Get ZPL equivalent code from the base64 Image string

ParamType
optionsZPLConverterOptions

Returns: any


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