Cordova plugin for Bixolon mobile printers using the official UPOS compliant API.
NOTE
For simplicity, only image (bitmap) printing are allowed.
- Android
- iOS (TODO)
$ cordova plugin add https://github.com/itsKaynine/cordova-plugin-bixolon-printing.git
$ phonegap local plugin add https://github.com/itsKaynine/cordova-plugin-bixolon-printing.git
cordova.plugins.BixolonPrinting.printConfig = {
lineFeed: 3,
formFeed: false
};
cordova.plugins.BixolonPrinting.connect(successCallback, errorCallback, {
logicalDeviceName: String,
deviceBus: int, // cordova.plugins.BixolonPrinting.DEVICE_BUS
address: String,
secure: Boolean
});
cordova.plugins.BixolonPrinting.printBitmap(successCallback, errorCallback, {
base64Image: String,
width: int,
brightness int, // 0 to 100 (Bixolon recommeded 13 to 88)
alignment: int // cordova.plugins.BixolonPrinting.ALIGNMENT
});
cordova.plugins.BixolonPrinting.disconnect(successCallback, errorCallback);
// Put your base64 encoded image string here
var b64Image = "<Base64 Encoded Image>";
function alertError(err) {
alert("ERROR: " + err);
};
// Define connection to printer
var connection = {
logicalDeviceName: "SPP-R310",
deviceBus: cordova.plugins.BixolonPrinting.DEVICE_BUS.WIFI,
address: "10.0.1.21",
secure: false
};
// Connect to printer
cordova.plugins.BixolonPrinting.connect(
function(res) {
// Printing options
var printObj = {
base64Image: b64Image,
width: 500,
brightness: 50,
alignment: cordova.plugins.BixolonPrinting.ALIGNMENT.CENTER
};
// Perform printing
cordova.plugins.BixolonPrinting.printBitmap(
function(res) {
alert("SUCCESS");
// ... Do other things or just disconnect()
},
alertError,
printObj
);
},
alertError,
connection
);
{
BLUETOOTH: 0,
ETHERNET: 1,
USB: 2,
WIFI: 3,
WIFI_DIRECT: 4
};
{
ASIS: -11,
LEFT: -1,
CENTER: -2,
RIGHT: -3
};
Device bus | Address |
---|---|
BLUETOOTH | BT MAC address |
ETHERNET | IP address |
USB | None |
WIFI | IP address |
WIFI_DIRECT | WLAN MAC address |
- Bixolon - Bixolon official site
- Base64 Image - Used many times while testing
- alfonsovinti/cordova-plugin-bixolon-print - Plugin inspired by
This software is released under the Apache 2.0 License.