Open rapPayne opened 4 years ago
Hi, did you load a template onto the printer using the brother utility tool?
Sending a template to the printer isn't support by the plugin yet so the template needs to be imported manually
Actually I've just checked out the brother documentation, RJ-2150 does indeed not support template printing.
But that doesn't mean this plugin can't support it, do you usually use pdf, images or text to print using your printer?
In this POC I am just printing text. The example you have on https://pub.dev/packages/brotherlabelprintdart#-example-tab- is perfect.
We're going to need to develop a new functionnality to support text print. I checked out the Brother SDK, it doesn't seem to support text print natively, we could auto convert text into either an image or a pdf. I'll take a futher look at it to see which one is the more suitable.
Unfortunatly I don't have the printer anymore, will you be able to test ?
I sure do. I'm happy to work with you on this. I can for sure test and I'll be glad to work with the Dart and Flutter side. It's the android side of the Method Channels that I'm weaker on.
Great! Thanks for the help
I will make a first commit to support pdf and images print (I'm unable to test so it will be very experimental). If you can test it and maybe fix the issues you can find, we should be able to have it working without doing too many revisions.
I'll keep you up to date ;)
I've pushed a new version into the experimental branch.
It should add image and pdf support, it is untested so it's pretty likely to fail. Example has been updated aswell.
Please let me know if you tested it :slightly_smiling_face:
Getting closer. Please accept my PR. After my changes there's an error returning from android. Whether printing an Image in BrotherLabelPrintDart.printLabelFromImage or BrotherLabelPrintDart.printLabalFromPdf, the error is
"An error occured : PlatformException(error, byte[] cannot be cast to java.util.List, null)"
Could it be in your Kotlin code that the
private fun printLabelFromPdf(printerIp: String, printerModel: Int, data: List<Int>, numberOfPages : Int) : String{
... should be ...
private fun printLabelFromPdf(printerIp: String, printerModel: Int, data: Int[], numberOfPages : Int) : String{
or something? ¯_(ツ)_/¯
Or maybe it's in the onMethodCall? call.argument<List<Int>>("data")
might should be call.argument<Int[]>("data")
?
I'm totally guessing here.
Thanks ! Your changes have been merged
I've converted List
If you can try it out :slightly_smiling_face:
Tested it out. Again, closer. I tried a bunch of stuff but in the end couldn't get it to work on the Android side. The error is:
java.lang.ClassCastException: byte[] cannot be cast to java.lang.Byte[]
We're passing an Array
I don't know for sure, but I'm about 60% confident that Kotlin can convert an int to a Byte. So maybe iterate through the list of ints and put them in a list of Bytes? Maybe .map() it?
Haha 60% is good enough, let's try it ! :smile:
What I don't get is when we are passing a strong typed List<int>
on dart's side we get a byte[]
on Kotlin's side, meanwhile passing a List<String>
gets us a List<String>
.
Maybe it is just the error interpreting the List<int>
as byte[]
, I'll give Int[]
a try.
It's not working, still got a type cast error
Finally got it to work, at least until "Printing on $ip_addresse". I can't test further. In the documentation you have a table of how types get passed through channel : https://flutter.dev/docs/development/platform-integration/platform-channels?tab=android-channel-kotlin-tab
Solution was Uint8List -> ArrayByte
Let me know if it does print something :wink:
Progress! When printing the image, we get ...
D/BROTHER LABEL PRINT(10681): Printing on : 192.168.68.128 D/BROTHER LABEL PRINT(10681): Thread started W/System.err(10681): java.lang.RuntimeException: Buffer not large enough for pixels W/System.err(10681): at android.graphics.Bitmap.copyPixelsFromBuffer(Bitmap.java:625) W/System.err(10681): at com.reefind.brotherlabelprintdart.BrotherlabelprintdartPlugin$printLabelFromImage$thread$1.run(BrotherlabelprintdartPlugin.kt:84) W/System.err(10681): at java.lang.Thread.run(Thread.java:764) D/BROTHER LABEL PRINT(10681): Print finished
When printing the PDF we get:
E/BROTHER PRINTER ERROR(10681): ERROR_OS_VERSION_NOT_SUPPORTED
p.s. I talked to some people from Brother last night. I may be able to get us some support from the company itself. I'll let you know.
Okay, I'll try to increase the buffer size for the image print.
The PDF error is kinda odd, what device are you testing on ?
That would be awesome ! Please let me know if you have any more info on that :smiley:
This issue is still open and the related features are not working yet. If you need these features and are willing to help with testing feel free to contact me.
When printing to an RJ-2150, I get this...
So maybe your library doesn't support an RJ-2150?