I'm currently working on developing an app in ExtJs that involves printing a PDF label for warehouse purposes using Zebra smartphones connected to printers via Bluetooth. I've been trying to implement Zebra's APIs specifically the BrowserPrint library, but haven't had much success. The library does load correctly, but I'm facing some challenges with the implementation.
Here is the function I am currently focused on:
onPrintClick() {
var selected_device;
var devices = [];
BrowserPrint.getDefaultDevice("printer", function(device) {
//Add device to list of devices and to html select element
selected_device = device;
devices.push(device);
Ext.Msg.alert(device.name ? device.name : 'Unknown Device');
//Discover any other devices available to the application
BrowserPrint.getLocalDevices(function(device_list) {
for(var i = 0; i < device_list.length; i++) {
var device = device_list[i];
if(!selected_device || device.uid != selected_device.uid) {
devices.push(device);
Ext.Msg.alert(device.name);
}
}
}, function(){alert("Error getting local devices")},"printer");
}, function(error){
alert(error);
});
}