1

I am trying to print from my cordova application to a bixolon srp-350iii thermal printer using the usb interface.

My BixolonPrint.java includes the following:

case BixolonPrinter.MESSAGE_USB_DEVICE_SET:
Log.d(TAG, "perform mHandler: MESSAGE_USB_DEVICE_SET");
if (msg.obj == null) {
    BixolonPrint.this.cbContext.error("USB printer not found");

} else {
    //connect printer

}

This is my index.html

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *; img-src 'self' data: content:;">
        <meta name="format-detection" content="telephone=no">
        <meta name="msapplication-tap-highlight" content="no">
        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
        <link rel="stylesheet" type="text/css" href="css/index.css">
        <title>Bixolon Test</title>

          <link rel="stylesheet" href="css/bootstrap.min.css">
          <script src="js/jquery.min.js"></script>
          <script src="js/bootstrap.min.js"></script>

    </head>
    <body>

        <div class="container">

        <h2>Bixolon Test</h2>
        <button type="button" class="btn btn-default btn-lg btn-block" onclick="PrintThisData(this, 'red')">CLICK TO TEST PRINT</button>
        <script>
        function PrintThisData(elmnt,clr) {
            elmnt.style.color = clr;

            // compose text
            cordova.plugins.bixolonPrint.addLine({
                text: "This is a test message. Jing Yeng\r\n",
                textAlign: cordova.plugins.bixolonPrint.TextAlign.CENTER,
                fontStyle: cordova.plugins.bixolonPrint.FontStyle.BOLD
            });
            cordova.plugins.bixolonPrint.addHr();
            cordova.plugins.bixolonPrint.addLine("#@*èòçìàé€");
            // finally print
            cordova.plugins.bixolonPrint.printText(
                function (response) {
                    alert("Ticket printed successfully. Press OK to proceed!")
                },
                function (error) {
                    alert("Failed: " + error)
                },
                {
                    codePage: cordova.plugins.bixolonPrint.CodePage.CP_1252_LATIN1
                }
            );
        }
        </script>


        </div>

        <script type="text/javascript" src="cordova.js"></script>
        <script type="text/javascript" src="js/index.js"></script>
    </body>
</html>

I am not able to detect the printer from my android device running android 4.4 after installing the generated apk on my device. the printer is already connected to the android device using a usb.

What could be the issues with this?

Andrés Alcarraz
  • 1,570
  • 1
  • 12
  • 21
nick
  • 333
  • 1
  • 4
  • 15

0 Answers0