Simplest Zebra Browser Print Example?

R Robert Davidson 3 years 7 months ago
1835 6 0

I have tried to simplify the DevDemo.js scripts for my purposes, but have not had any success. I am on an Internet Explorer 11 setup. The Zebra GK420d was successfully configured and works with the index.html sample. I try with the below function and nothing happens inside the BrowserPrint command:

var format_start = "^XA^LL200^FO80,50^A0N36,36^FD";
var format_end = "^FS^XZ";
var txtToPrint = "Itza Miragul";
 
function printTest() {
    testPresent(); // Added function to attached BrowserPrint-1.0.4.min.js to test if script could see it. This alert pops. Remove this line to use original BrowserPrint-1.0.4.min.js instead of attached version.
    BrowserPrint.getDefaultDevice('printer', function(printer)
        {
            alert(printer.name); // This alert does not pop - why???
            printer.send(format_start + txtToPrint + format_end);
        },
        function(error_response)
        {
            // This alert doesn't pop either
            alert(    "An error occured while attempting to connect to your Zebra Printer. " +
                    "You may not have Zebra Browser Print installed, or it may not be running. " +
                    "Install Zebra Browser Print, or start the Zebra Browser Print Service, and try again.");
        }
    );
    alert("After BrowserPrint"); //This alert pops
}

I'm a novice to java so I probably managed to make some sort of syntax error, but I get no feedback about where it might be.
Any help would be greatly appreciated.
 
Best Regards,
 
Robert

Please Register or Login to post a reply

6 Replies

E Eugene Khomchenko

How to print EPL commands with Zebra Browser Print?Printer: Zebra LP 2844.
Language: only EPL.
Connection: USB.

P Philip Hemmers

Hi Robin,

I am attempting to integrate BrowserPrint into a new javascript UI (using the React library). I am running into some errors. Hopefully, you able to help?? If so please contact me. If not, please send me in the right direction.

Thank you,

Phil Hemmers

D Dang Dang

i have a problem when i access a sample zebra browser print demo .the printer dont cut paper .when i click print label . the printer dont cut page . pls help me

J Javed Bashir

Is there a way to fix the insecure https://localhost9101 issue when printing from the web. We've got the BrowserPrint utility to print from a public website, but when the print function is called it throws up this insecure site.

E Efkan YILMAZ

Hi Robert, You are not checking if the default printer is set.  Browser Print does not use the OS default printer.  It has to be set by the user, or you have to give them the option to choose from connected printers.  BrowserPrint.getDefaultDevice runs asynchronously.

var format_start = "^XA^LL200^FO80,50^A0N36,36^FD";
var format_end = "^FS^XZ";
var txtToPrint = "Itza Miragul";

function printTest() {
    testPresent(); // Added function to attached BrowserPrint-1.0.4.min.js to test if script could see it. This alert pops. Remove this line to use original BrowserPrint-1.0.4.min.js instead of attached version.
    BrowserPrint.getDefaultDevice('printer', function(printer)
        {
            if((typeof printer != "undefined") && (printer.connection == undefined))
            {
                alert("No Printer Found");
                    // give option to choose printer
            }
            else{
                alert(printer.name); // This alert does not pop - why???
                printer.send(format_start + txtToPrint + format_end);
            }
        },
        function(error_response)
        {
            // This alert doesn't pop either
            alert(    "An error occured while attempting to connect to your Zebra Printer. " +
                    "You may not have Zebra Browser Print installed, or it may not be running. " +
                    "Install Zebra Browser Print, or start the Zebra Browser Print Service, and try again.");
        }
    );
    alert("After BrowserPrint"); //This alert pops
}

R Robert Davidson

Robin,

Thank you for the explanation. I had thought that the printer the user chose as default printer on index.html would be sticky.

In my case I know the printer is going to be the same each time and asking the user to reselect each time the page is loaded would adversely affect workflow. If possible, I'd like to specify the printer without calling getDefaultDevice.  Is there a getDevice(name) that could be used instead?

Best Regards,

Robert Davidson

CONTACT
Can’t find what you’re looking for?