esc_pos_utils icon indicating copy to clipboard operation
esc_pos_utils copied to clipboard

[Feature Request] USB support

Open sergiotucano opened this issue 3 years ago • 7 comments

This feature is possible? Printing in Windows / Linux USB printers.

sergiotucano avatar Apr 02 '21 01:04 sergiotucano

I need that function too

MarcoGolin avatar Apr 26 '21 15:04 MarcoGolin

Same request

A1000carZ avatar Jun 25 '21 23:06 A1000carZ

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

denisrudnei avatar Nov 07 '21 03:11 denisrudnei

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());
    }
  }

Abdulazeezvp avatar Mar 24 '22 12:03 Abdulazeezvp

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 avatar May 27 '22 21:05 samo92

@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.

Abdulazeezvp avatar May 28 '22 17:05 Abdulazeezvp

Oh noooo! flutter web is not supported, i make a quick sample to test the repo.

samo92 avatar May 29 '22 03:05 samo92