feat: ticket printer
This commit is contained in:
@@ -1398,4 +1398,39 @@ class PrintDataoutputs {
|
||||
|
||||
return bytes;
|
||||
}
|
||||
|
||||
Future<List<int>> printTicket(
|
||||
int totalPrice, Uint8List imageQris, int paper) async {
|
||||
List<int> bytes = [];
|
||||
|
||||
final profile = await CapabilityProfile.load();
|
||||
final generator =
|
||||
Generator(paper == 58 ? PaperSize.mm58 : PaperSize.mm80, profile);
|
||||
|
||||
final img.Image? orginalImage = img.decodeImage(imageQris);
|
||||
bytes += generator.reset();
|
||||
|
||||
// final Uint8List bytesData = data.buffer.asUint8List();
|
||||
// final img.Image? orginalImage = img.decodeImage(bytesData);
|
||||
// bytes += generator.reset();
|
||||
|
||||
bytes += generator.text('Scan Ticket',
|
||||
styles: const PosStyles(bold: false, align: PosAlign.center));
|
||||
bytes += generator.feed(2);
|
||||
if (orginalImage != null) {
|
||||
final img.Image grayscalledImage = img.grayscale(orginalImage);
|
||||
final img.Image resizedImage =
|
||||
img.copyResize(grayscalledImage, width: 240);
|
||||
bytes += generator.imageRaster(resizedImage, align: PosAlign.center);
|
||||
bytes += generator.feed(1);
|
||||
}
|
||||
|
||||
bytes += generator.text('Price : ${totalPrice.currencyFormatRp}',
|
||||
styles: const PosStyles(bold: false, align: PosAlign.center));
|
||||
|
||||
bytes += generator.feed(4);
|
||||
bytes += generator.cut();
|
||||
|
||||
return bytes;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user