71 lines
2.1 KiB
Dart
71 lines
2.1 KiB
Dart
import 'dart:typed_data';
|
|
|
|
import 'package:charset_converter/charset_converter.dart';
|
|
import 'package:esc_pos_utils/esc_pos_utils.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'dart:io';
|
|
import 'package:image/image.dart';
|
|
|
|
|
|
|
|
Future<List<int>> getReceipt() async {
|
|
final profile = await CapabilityProfile.load();
|
|
final generator = Generator(PaperSize.mm80, profile);
|
|
List<int> bytes = [];
|
|
generator.setGlobalCodeTable('CP866');
|
|
Uint8List firstCol = await CharsetConverter.encode('cp866', 'Русский');
|
|
|
|
bytes += generator.textEncoded(firstCol, styles: const PosStyles(align: PosAlign.left));
|
|
|
|
bytes +=
|
|
generator.text('Align center', styles: const PosStyles(align: PosAlign.center));
|
|
bytes += generator.text('Align right',
|
|
styles: const PosStyles(align: PosAlign.right), linesAfter: 1);
|
|
|
|
bytes += generator.row([
|
|
PosColumn(
|
|
text: 'col3',
|
|
width: 3,
|
|
styles: const PosStyles(align: PosAlign.center, underline: true),
|
|
),
|
|
PosColumn(
|
|
text: 'col6',
|
|
width: 6,
|
|
styles: const PosStyles(align: PosAlign.center, underline: true),
|
|
),
|
|
PosColumn(
|
|
text: 'col3',
|
|
width: 3,
|
|
styles: const PosStyles(align: PosAlign.center, underline: true),
|
|
),
|
|
]);
|
|
|
|
// bytes += generator.text('Text size 200%',
|
|
// styles: const PosStyles(
|
|
// height: PosTextSize.size2,
|
|
// width: PosTextSize.size2,
|
|
// ));
|
|
//
|
|
// // Print barcode
|
|
// final List<int> barData = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 4];
|
|
// bytes += generator.barcode(Barcode.upcA(barData));
|
|
|
|
bytes += generator.feed(2);
|
|
bytes += generator.cut();
|
|
return bytes;
|
|
}
|
|
|
|
Future<List<int>> getReceiptImg() async {
|
|
final profile = await CapabilityProfile.load();
|
|
final generator = Generator(PaperSize.mm80, profile);
|
|
List<int> bytes = [];
|
|
generator.setGlobalCodeTable('CP866');
|
|
final ByteData data = await rootBundle.load('assets/images/aman_kassa_check.png') as ByteData;
|
|
final Uint8List imgBytes = data.buffer.asUint8List();
|
|
final Image? image = decodeImage(imgBytes);
|
|
// Using `ESC *`
|
|
bytes += generator.image(image!);
|
|
bytes += generator.feed(2);
|
|
bytes += generator.cut();
|
|
return bytes;
|
|
} |