Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to print images via USB printer #7

Open
shinxxxxwon opened this issue Feb 15, 2022 · 3 comments
Open

How to print images via USB printer #7

shinxxxxwon opened this issue Feb 15, 2022 · 3 comments

Comments

@shinxxxxwon
Copy link

I followed your example and tried printing via USB. Text was fine. But the image is output as text and the layout is messed up.

Does it not support image output by any chance?

I am attaching my source.

connect

_connect(int vendorId, int productId) async {
    bool? returned = false;
    try {
      returned = await flutterUsbPrinter.connect(vendorId, productId);
    } on PlatformException {
      //response = 'Failed to get platform version.';
    }
    if (returned!) {
      setState(() {
        connected = true;
      });
    }
  }

getDevice

_getDevicelist() async {
    List<Map<String, dynamic>> results = [];
    results = await FlutterUsbPrinter.getUSBDeviceList();

    print(" length: ${results.length}");
    setState(() {
      devices = results;
    });
  }

print

_print() async {
    try {
      // var data = Uint8List.fromList(
      //     utf8.encode(" Hello world Testing ESC POS printer..."));
      final ByteData bytes = await rootBundle.load('assets/images/1-1.JPG');
      final Uint8List list = bytes.buffer.asUint8List();
      await flutterUsbPrinter.write(list);
    } on PlatformException {
      print('no printing.');
    }
  }
@kechankrisna
Copy link
Owner

please take a look the example in link below:
https://github.com/kechankrisna/esc_pos_utils
it will demonstrate on how to get list to write in printer port.

@shinxxxxwon
Copy link
Author

Is the package available only for esc/pos printer? Can it be used with laser printers?

@kechankrisna
Copy link
Owner

Is the package available only for esc/pos printer? Can it be used with laser printers?

this package is only work with esc pos printer, if you want to try laster printers, I recommend you to use printing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants