Search code examples
javascriptiosthermal-printer

Star WebPRNT JS SDK defining model and port name


I will try and contact Star directly but just in case I get an answer quicker from SO crowd.

Their SDK here and their app here works fine with my SM-L200 printer using Star WebPRNT JS SDK.

However, trying to do the same using the SDK is not so straightforward. The app uses the HTML/JS code found here. But using the same thing from a Safari browser page (for example) does not work.

One must define the model and port name, from the instructions, but from the two JS functions defined in StarWebPrintTrader and StarWebPrintBuilder I cannot see where I could define the model and port name.

I would assume, the iOS app, gets the model and port name from the settings and passes it into the SDK.

How do I correctly send a print job to my SM-L200 using StarWebPrintTrader.prototype.sendMessage()?

Thanks

Edit: I contacted Star and I was told (non)mobile browsers at this moment are not able to communicate with Bluetooth devices. So unless native SDK code is used or JS WebPRNT run within Star WebPRNT browser, it is not possible to print to any Bluetooth devices.


Solution

  • Use something like this ..

    var trader = new StarWebPrintTrader({url: '//localhost:8001/StarWebPrnt/SendMessage'}); var builder = new StarWebPrintBuilder();

    And then do all the things you need.

    Note that the Star WebPRNT browser doesn't (or at least didn't) support https, so you may have issues if your host app requires https.

    The browser provides the bridge between the web application and the iOS's support for Bluetooth. The browser itself isn't aware of the printer directly as it has no Bluetooth support. The Star WebPRNT browser is Safari+Bluetooth support+localhost:8001.