cordova-brother-label-printer
cordova-brother-label-printer copied to clipboard
Initial support for iOS, Bluetooth printing
Todo
-
Label size is currently hard-coded and specified on calls to setPrinter
-
The supported printer list only contains printers I have tested personally, Brother QL-720NW and Brother QL-820NWB. With changes to allow for the changing of the label type, this would likely support all brother label printers, but it needs to be tested by someone with access.
-
iOS has bluetooth issues according to @Ayiga in #10
-
Documentation/readme needs to be updated.
-
Need to test! Anyone have a basic iOS Cordova app to test this with? Should we include a boilerplate example with this plugin to help users get started?
@Ayiga are you able to build?
Building status: error (List<Bitmap> cannot be converted to ArrayList<Bitmap>)
https://github.com/gordol/cordova-brother-label-printer/pull/11/files#diff-7ffdcc51506a24e861e75e002ed22eddR19
Hi, for the life of me, I cannot seem to call the findPrinters function, do you perhaps know how to translate this typescript to javascript?
Sample:
function findPrinters(success: (printers: Printer[]) => void, failure: (reason: string) => void): void
What I've got: cordova.plugins.brotherPrinter.findPrinters(function (a) { alert(a); }, viewModel.onSuccess, viewModel.onError);
or even this does not want to work:cordova.plugins.brotherPrinter.findPrinters(viewModel.onSuccess, viewModel.onError);
Thank you for the assistance!
On Fri, Aug 18, 2017 at 11:20 AM, Thomas Gordon Lowrey IV < [email protected]> wrote:
https://github.com/gordol/cordova-brother-label-printer/ pull/11/files#diff-7ffdcc51506a24e861e75e002ed22eddR19
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/gordol/cordova-brother-label-printer/pull/11#issuecomment-323304353, or mute the thread https://github.com/notifications/unsubscribe-auth/ATzouekyVnyr6i5vOXsvHRzLNH5Bg6I2ks5sZVdtgaJpZM4O7Ku4 .
@dev-fJ-del You should just be able to call findPrinters(). It takes two parameters, a success callback, and a failure callback.
Your second example looks correct to me.
findPrinters(onSuccess, onError);
That being said, I have not actually tested this PR yet, that's why it's on the dev branch.
Can you send any log outputs? You should see some log messages if any printers are found. Are you receiving any errors?
Ok, I got it to work up until where it calls the printViaSDK, I get the error: "ERROR_WRONG_CUSTOM_INFO" I checked the sdk docs :
Error: Wrong information in custom paper setting file
No idea what to do from here on. The printer I'm using is the RJ-4040
This is some of the new stuff... Hmm...
@Ayiga was this pulled over from brother by mistake, or did you need this? https://github.com/gordol/cordova-brother-label-printer/blob/9d882751c985589cf2ddf872b3e4dfc39904f13f/src/android/Common.java#L87-L88
@dev-fJ-del Try modifying this line: https://github.com/gordol/cordova-brother-label-printer/blob/9d882751c985589cf2ddf872b3e4dfc39904f13f/src/android/BasePrint.java#L343
to
mPrinterInfo.customPaper = customSetting;
Basically, remove the CUSTOM_PAPER_FOLDER bit... and let me know if it works?
@gordol I can build what I had currently without issues. I'll have to repull this repo to make sure everything still works on this end.
as far as the CUSTOM_PAPER_FOLDER
setting, it was just code that was copied from Brother. I did a quick pass to remove or modify stuff that I thought wasn't necessary, and I may have missed some things. I believe the custom paper settings are for larger printers, but I'm not certain, they are likely not necessary.
I've purposely been triggering a network error to occur when calling printViaSDK by having my ipad connected to a different network than that of the brother printer, however the callback never gets runned, instead I see this in my safari and xcode consoles error: Error occured while WLAN printing. Which is line 557 in BrotherPrinter.m file.
https://github.com/gordol/cordova-brother-label-printer/blob/dev/src/ios/BrotherPrinter.m#L557
It would be great if the callback actually got triggered with a good error as a response that way I can handle that on the js side. Otherwise, the js side has no idea why the printer didn't print since the callback never gets invoked. Any help would be appreciated.
@VictorCoding What is outputted by this line? NSLog(@"Communication Result: %d", result);
Is it empty?
@gordol i get a 0
I'm not super familiar with this IOS code, but looks like the meat of that is happening here: https://github.com/gordol/cordova-brother-label-printer/blob/dev/src/ios/BRWLANPrintOperation.m
communicationResultForWLAN
is a boolean.
What do you have if you dump: wlanOperation.resultStatus
? resultStatus
comes from getPTStatus
via: https://github.com/gordol/cordova-brother-label-printer/blob/dev/src/ios/libs/BRPtouchPrinterKit.framework/Headers/BRPtouchPrinter.h
My objective C isn't very strong, I'll need to brush up on some basics before I can be of more help.
Can you put some debug logging here, to see if your printer is ready?
https://github.com/gordol/cordova-brother-label-printer/blob/dev/src/ios/BRWLANPrintOperation.m#L61
I don't know the details of the IOS Brother SDK, but it seems to me, that what you want are two things... Callbacks for failure to associate with the printer, and a callback for failure to print.
On Android, we don't allow a call to printViaSDK
unless a printer is found.
resultstatus
should have what you need, right?
@gordol The printer is NOT ready so it skips to line 77. In my javascript implementation for setPrinter
's my success callback is invoked, which then I call printViaSDK
, but that's when I dont get my callback invoked.
btw, thanks for your assistance even if your objective c game is rusty. at least it's better than me, i dont know objective c at all.
@gordol @VictorCoding
I believe this is due to the original code for handling the callback in the javascript file:
https://github.com/gordol/cordova-brother-label-printer/blob/dev/www/printer.js#L24
And the Original: https://github.com/gordol/cordova-brother-label-printer/blob/master/www/printer.js#L15
As you can see in that file, all errors just get console logged instead of passed back to the user. It's one of the things I worked to fix with this pull request:
https://github.com/ayiga/cordova-brother-label-printer/blob/master/www/printer.js#L50
But, I haven't been able to come back to this project and update it so that it's "good enough". I will push what I have, but I have added some quick and dirty solutions for what I needed in my particular use case without really addressing the talking points @gordol brought up before. I just haven't had the time to come back, and give it the attention it needs, unfortunately. :(
Hello, Thanks for this great plugin for iOS. I successfully print label for my Brother QL-810 printer. But currently I am receiving one issue, that I am receiving printer in onFailure of findNetworkPrinter method. Please find following code please guide me where I am doing wrong.
cordova.plugins.brotherPrinter.findNetworkPrinters((success) => {}, (error) => {})
thanks in advance.
@chetuBhadra93 could you provide the actual data you're getting from the onFailure
callback?
Hello @gordol , @VictorCoding @Ayiga ....
Not sure what version of XCode you guys are using ... After installing this plugin dev branch, my project will not even compile in Xcode .... please see more detail on #34
@arcadius im using version 9.4.
Hellp @gordol and @VictorCoding I have use your brother label printer sdk.
SDK working fine. When I call printviaSDK method. Getting success response. But printer doesn't print any image. response getting success but noting happen.