This page shows the ability to print to a bluetooth printer from the GSW Industrial Browser
This feature is currently only available for Zebra Bluetooth Printers
This demo is using the gswconnectbot object. For more information click here:
var GSW = GSW || {};
GSW.Tests = GSW.Tests || {};
GSW.Tests.onDeviceReady = function() {
// Cordova is now initialized. Have fun!
console.log('Now running cordova-' + cordova.platformId + '@' + cordova.version);
GSW.Tests.print = function() {
//Gathering User Input
var headingInput = document.getElementById("heading").value;
var text = document.getElementById("text").value;
var heading = headingInput.toUpperCase();
//Formatting for Printer
var headingFormat = "! U1 JOURNAL\r\n" +
"! U1 SETLP 4 0 47\r\n";
var textFormat = "! U1 SETLP 7 0 24\r\n";
var barcode = "! U1 CENTER\r\n" +
"! U1 B 128 1 1 100 0 0 59285691 ST 187.10 T 2.60\r\n";
// Inserting user input into correct format
var finalHeading = headingFormat + heading + "\r\n";
var finalText = textFormat + text + "\r\n";
// Creating final label string to print
var label = finalHeading + finalText + barcode;
navigator.gswconnectbot.printString(function() {
document.getElementById("printSuccess").innerHTML = "Print Success"
},
function(e) {
document.getElementById("printSuccess") = "print error: " + e;
}, label);
}
GSW.Tests.printDemo = function() {
var label = "! U1 JOURNAL\r\n" +
"! U1 SETLP 4 0 47\r\n" +
" YOURCO RETAIL STORES\r\n" +
"! U1 SETLP 7 0 24\r\n" +
" 14:40 PM Thursday, 06/04/20\r\n" +
" Quantity Item Unit Total\r\n" +
" 1 Babelfish $4.20 $4.20\r\n" +
" Tax: 5% $0.21\r\n" +
"! U1 SETSP 5\r\n" +
" Total:! U1 SETSP 0\r\n" +
" $4.41\r\n" +
"Thank you for shopping at YOURCO\r\n" +
"! U1 CENTER\r\n" +
"! U1 B 128 1 2 100 0 0 59285691 ST 187.10 T 2.60\r\n";
navigator.gswconnectbot.printString(function() {
document.getElementById("printSuccess").innerHTML = "Print Success"
},
function(e) {
document.getElementById("printSuccess") = "print error: " + e;
},
label);
}
document.getElementById("userInput").addEventListener("click", GSW.Tests.print);
document.getElementById("demoPrint").addEventListener("click", GSW.Tests.printDemo);
}
document.addEventListener('deviceready', GSW.Tests.onDeviceReady, false);