bluetooth_print icon indicating copy to clipboard operation
bluetooth_print copied to clipboard

Printing images

Open HamzaMihfad opened this issue 1 year ago • 3 comments

Hi, thanks for creating this awesome package, but there is a small bug that can be fixed. Can you please set the default with to a value different than 0 when printing an image, because it gives an error, this is the documentation code:

list1.add(LineText(type: LineText.TYPE_IMAGE, x:10, y:10, content: base64Image,));

but when I apply it, I get this error: E/AndroidRuntime( 8339): FATAL EXCEPTION: ThreadFactoryBuilder_ThreadPool_1 E/AndroidRuntime( 8339): Process: com.example.goofood_dashboard, PID: 8339 E/AndroidRuntime( 8339): java.lang.IllegalArgumentException: width and height must be > 0 E/AndroidRuntime( 8339): at android.graphics.Bitmap.createBitmap(Bitmap.java:1111) E/AndroidRuntime( 8339): at android.graphics.Bitmap.createBitmap(Bitmap.java:950) E/AndroidRuntime( 8339): at com.gprinter.command.GpUtils.resizeImage(GpUtils.java:143) E/AndroidRuntime( 8339): at com.gprinter.command.EscCommand.addRastBitImage(EscCommand.java:922) E/AndroidRuntime( 8339): at com.example.bluetooth_print.PrintContent.mapToReceipt(PrintContent.java:95) E/AndroidRuntime( 8339): at ....

It took me 2 hours to figure out that I should add a width different than 0 like this: list1.add(LineText(type: LineText.TYPE_IMAGE, x:10, y:10, content: base64Image, width: 100));

blease fix the documentation or change the default with value.

Thank you!

HamzaMihfad avatar Jun 20 '23 16:06 HamzaMihfad

@HamzaMihfad How do you determine the width of the image?

kwarnkham avatar Jun 24 '23 17:06 kwarnkham

@kwarnkham list1.add( LineText( type: LineText.TYPE_IMAGE, content: base64Image, width: 100, ));

HamzaMihfad avatar Jun 24 '23 17:06 HamzaMihfad

@HamzaMihfad is your bold is working list.add(LineText(type: LineText.TYPE_TEXT, content: 'SO # 2343', weight: 1, linefeed: 1));

list.add(LineText(type: LineText.TYPE_TEXT, content: 'SO # 2343', weight: 0, linefeed: 1));

in my case both are working same. It is not printing bold.

BilalAhmedx1998 avatar Jul 13 '23 08:07 BilalAhmedx1998