esc_pos_utils
esc_pos_utils copied to clipboard
[Feature Request] USB support
This feature is possible? Printing in Windows / Linux USB printers.
I need that function too
Same request
In order to print via USB, simply write the return as if it were in a file.
Linux:
File('/dev/usb/lp0').writeAsBytes(bytes);
Windows:
File('\\computer-name\share').writeAsBytes(bytes);
I'm using this method to communicate with the printer
Video with the system working like this: https://www.youtube.com/watch?v=NZngrlGkISU
Using Flutter usb printer package we can print with ESC pos printer, but problem is its not working good for images as expected, Don't know whether its the problem with esc_pos_utils package or flutter usb printer package. we can print as follows:
///list connected printers using flutter usb package
static Future<List> getAllUsbDevices() async {
List<Map<String, dynamic>> results = [];
results = await FlutterUsbPrinter.getUSBDeviceList();
return results;
}
///connect to a printer like this
static Future<bool> connectUsbPrinter(
{required String vendorId, required String productId}) async {
bool? returned;
try {
returned = await flutterUsbPrinter.connect(
int.parse(vendorId), int.parse(productId));
log('device connecetd');
} catch (e) {
returned = false;
log(e.toString());
//response = 'Failed to get platform version.';
}
return returned ?? false;
}
///prepare message using this package(esc pos utils)
static Future<List<int>> prepareMessage() async {
final profile = await CapabilityProfile.load();
late final Generator generator;
generator = Generator(PaperSize.mm58, profile);
List<int> bytes = [];
bytes += generator.text('Aa Bb Cc Dd Ee Ff Gg Hh');
bytes += generator.cut(mode: PosCutMode.partial);
return bytes;
}
///print message with help of flutter usb printer package.
static Future<void> doPrint() async {
List<int> list = await prepareMessage();
try {
await flutterUsbPrinter.write(Uint8List.fromList(list));
} catch (e) {
log('catch ' + e.toString());
}
}
Hi everyone, I have the same problem too, does anyone have a suggestion regarding this issue? My printer is an Epson TM-T88V, and it only has an USB and ecom port to communicate with my computer.
@samo92 my suggestion is, you can use pos_printer_manager(git repo) (In pub.dev) package, which is a intergrated solution for usb, bluetooth and network. And its working good. (Pos printer manager is devleoped with help of utils package). In some new printers, you might have to use image bit raster option.
Oh noooo! flutter web is not supported, i make a quick sample to test the repo.