bluetooth_print
bluetooth_print copied to clipboard
can't print image latest version ^4.3.0
hi, i'm using latest version bluetooth_print: ^4.3.0, i can't print image
OutlinedButton(
child: Text('print receipt(esc)'),
onPressed: _connected
? () async {
Map<String, dynamic> config = Map();
List<LineText> list = [];
list.add(LineText(
type: LineText.TYPE_TEXT,
content: 'hi this is a test',
weight: 1,
align: LineText.ALIGN_CENTER,
));
ByteData data = await rootBundle
.load("assets/images/bluetooth_print.png");
List<int> imageBytes = data.buffer.asUint8List(
data.offsetInBytes, data.lengthInBytes);
String base64Image = base64Encode(imageBytes);
list.add(LineText(
type: LineText.TYPE_IMAGE,
content: base64Image,
align: LineText.ALIGN_CENTER,
linefeed: 1));
await bluetoothPrint.printReceipt(config, list);
}
: null,
),
Hi, i get the same error. is there any solution ?
@ezraricad2 i use this package https://pub.dev/packages/flutter_bluetooth_printer after no solution or reply
hi i was facing the same error i resolved by adding height and width
list2.add(LineText(type: LineText.TYPE_IMAGE, content: base64Image, height: 90, width: 90, align: LineText.ALIGN_CENTER,));
hi i was facing the same error i resolved by adding height and width
list2.add(LineText(type: LineText.TYPE_IMAGE, content: base64Image, height: 90, width: 90, align: LineText.ALIGN_CENTER,));
it works!!!!!
Don't work in my case 😔 . I have the next code:
ByteData data = await rootBundle.load(ImageUtils.getImagePath("logo_ticket.png"));
List<int> imageBytes = data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes);
String base64Image = base64Encode(imageBytes);
header.add(LineText(
type: LineText.TYPE_IMAGE,
height: 350,
width: 350,
content: base64Image,
align: LineText.ALIGN_CENTER));
Don't work in my case 😔 . I have the next code:
ByteData data = await rootBundle.load(ImageUtils.getImagePath("logo_ticket.png")); List<int> imageBytes = data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes); String base64Image = base64Encode(imageBytes); header.add(LineText( type: LineText.TYPE_IMAGE, height: 350, width: 350, content: base64Image, align: LineText.ALIGN_CENTER));
hi, try first to comment everything else and see if the image is printing. if it doesn't try to debug by setting break point before print or print in the console base64Image and see if there actually image to print.
Thanks
try this one its worked for me.
List<LineText> list1 = [];
ByteData data =
await rootBundle.load("assets/static_images/ic-hmc-black.png");
List<int> imageBytes =
data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes);
String base64Image = base64Encode(imageBytes);
list1.add(LineText(
type: LineText.TYPE_IMAGE,
x: 10,
y: 10,
height: 200,
width: 200,
content: base64Image,
),
);
@Zia9335 Its working but position not start exactly to next label once first label done printing. Setting correct width and height with gap in labell configuration.