AbobosSoftware / cordova-plugin-brother-label-printer

Cordova and Capacitor plugin for Bother Label Printers
MIT License
10 stars 16 forks source link

No label returned #19

Closed cpgb85 closed 1 year ago

cpgb85 commented 4 years ago

I love the plugin. it actually returns printers for me, but it won't return the label being used. am i missing something?

robr2112 commented 4 years ago

Hi, have you resolved this?

I'm not an expert with this plugin, but I do support the Brother SDK (primarily the iOS version). However, I'm not an expert with QL-series models either (different division of Brother). But, I'll try to assist you if you still need it.

The various FindXXXPrinters methods in this plugin will NOT include the "currently loaded" label type in the Printer object returned, from what I can tell from a brief look at the plugin code. So, it seems you are required to set the 'paperLabelName' field in Printer object yourself to the type of label being used, before you call "SetPrinter". So, this is not automatic.

NOTE: QL model printers know what type of label is inserted and the paper string passed into the SDK MUST match it. (This is NOT true with all models the SDK supports). However, I do NOT believe the SDK provides an API that allows you to "ask" the printer what type of label is currently loaded, for printer models that might support this feature.

If this is what you need, I can check this with the SDK developers to see if such a method exists. But, even IF the method exists, in both Android and iOS SDKs, it seems that you (or someone) would have to modify the plugin to use it. And, this would not work on all models, as I've stated.

Most likely, you will have to specify the 'paperLabelName' yourself, or allow user to choose it from a list that you provide, before you call SetPrinter.

Hope this helps.

-Rob

arcadius commented 1 year ago

Hello @cpgb85 As explained by @robr2112 , you will need to tell the API the type of label loaded in the printer. If you still think there is an issue to fix, please feel free to reopen this ticket please

robr2112 commented 1 year ago

Since writing my reply here a few years ago, I have learned something about printing to QL printers. And, my previous response was incorrect (as concerns the SDK, not the plugin).

If anyone wants to explore this in the future, the iOS SDK does in fact provide an API that allows retrieving the currently installed QL or PT printer label. It's the v3 "getLabelInfoStatus()" method. And, the labelID field in the resulting class object contains the ID that should match the "enum" values provided in the v3 SDK APIs.

NOTE: I believe the Android SDK has a similar capability.

WARNING: If you ever convert the plugin to use the v4 APIs for printing, the v3 enum MUST be converted to the v4 enum, because the enum values have changed between v3 and v4. The v4 SDK does not currently have a similar method available. But, a new method to do this will likely be added in a future v4 SDK update.

Anyway, there is nothing wrong with forcing user to choose a specific label from a list of options (and specify that to this plugin in the way it currently requires). But, if you must have the convenience of auto-detecting the currently installed label, it can be done.

-Rob

cpgb85 commented 1 year ago

So, what does this mean? Does this plugin support this?

arcadius commented 1 year ago

You are right @cpgb85 , this plugin and the Brother SDK do not detect the installed label. If you have access to the physical printer, you can check and know the installed label

robr2112 commented 1 year ago

@cpgb85 As arcadius mentioned, the plugin currently does not support the capability to detect the label. However, as I mentioned a few weeks ago, the SDK DOES actually have the capability (contrary to my original message).

On iOS, use the getLabelInfoStatus() function. Android SDK may be same or similar API. So, plugin could implement this if desired. But, it is not an available feature today.

Otherwise, a common way to support this in an App is to provide a GUI which shows a list of labels that you wish to support. Can be all or a subset of SDK-supported label sizes, your choice.

From this user selection, you can then use the currently available capability in the plugin to specify the label size. Or, if your app will use one and only one label size, you can hard-code the label size and you don't need to provide a GUI to allow user to select; but that is probably not the case.

@arcadius It may be nice some day to implement the SDK getLabelInfoStatus() function at print-time inside the plugin, and then it would not be necessary for the app to specify the label or provide a GUI. This is only a suggestion. I do not mean to add anything to your plate ;-)

Cheers, Rob

arcadius commented 1 year ago

Thank you very much @robr2112 for bringing up this getLabelInfoStatus() I was not aware it was available.

Please @cpgb85 , if you need this functionality urgently, please have a look and see whether you can add that to the plugin please. Thank you very much