A cordova plugin for bluetooth printer for android platform.
This code is being adapted from a fork of Cordova-Plugin-Bluetooth-Printer, of free use and modifications that will arise for the improvement of the plugin.
- Text
- POS
- ZPL and ZPL Commands
Using the Cordova CLI and NPM, run:
cordova plugin add https://github.com/TruewindIT/Cordova-Bluetooth-Printer-Plugin
Get list of paired bluetooth devices, including printers, if any:
BTPrinter.list(function(data){
console.log("Success");
console.log(data); \\list of printer in data array
},function(err){
console.log("Error");
console.log(err);
})
BTPrinter.status(function(data){
console.log("Success");
console.log(data) // bt status: true or false
},function(err){
console.log("Error");
console.log(err)
});
BTPrinter.connect(function(data){
console.log("Success");
console.log(data)
},function(err){
console.log("Error");
console.log(err)
}, "PrinterName")
BTPrinter.disconnect(function(data){
console.log("Success");
console.log(data)
},function(err){
console.log("Error");
console.log(err)
}, "PrinterName");
BTPrinter.printText(function(data){
console.log("Success");
console.log(data)
},function(err){
console.log("Error");
console.log(err)
}, "String to Print")
BTPrinter.printPOSCommand(function(data){
console.log("Success");
console.log(data)
},function(err){
console.log("Error");
console.log(err)
}, "0C")
//OC is a POS command for page feed