16 Replies Latest reply on Nov 7, 2018 8:22 AM by Philip Hemmers

    Simplest Zebra Browser Print Example?

    Robert Davidson

      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:

      <script type="text/javascript" src="js/jquery-1.11.1.min.js"></script>

      <script type="text/javascript" src="js/BrowserPrint-1.0.4.min.js"></script>

      <script type="text/javascript">

      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

      }

      </script>

      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

        • Re: Simplest Zebra Browser Print Example?
          Robin West

          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.

           

          <script type="text/javascript" src="js/jquery-1.11.1.min.js"></script>

          <script type="text/javascript" src="js/BrowserPrint-1.0.4.min.js"></script>

          <script type="text/javascript">

          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

          }

          </script>

          • Re: Simplest Zebra Browser Print Example?
            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.

             

             

            2017-08-21_23-13-55.jpg

            • Re: Simplest Zebra Browser Print Example?
              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