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

Printer not printing with original code #201

Open
srochacito opened this issue Oct 31, 2024 · 0 comments
Open

Printer not printing with original code #201

srochacito opened this issue Oct 31, 2024 · 0 comments

Comments

@srochacito
Copy link

I tried your example running in windows:

Future imprime() async {
final PaperSize paper = PaperSize.mm80;
final profile = await CapabilityProfile.load();
final printer = NetworkPrinter(paper, profile);

final PosPrintResult res = await printer.connect('10.0.0.168', port: 9100);

if (res == PosPrintResult.success) {
  testReceipt(printer);

  printer.disconnect();
}

print('Print result: ${res.msg}');

return res.msg;

}

I get a "success" message but nothing is printed.

I then used this code, and it worked:

void printTicketViaLan(List bytes) async {
Duration timeout = const Duration(seconds: 5);
var result = await Socket.connect('10.0.0.168', 9100, timeout: timeout)
.then((Socket socket) {
socket.add(bytes);
socket.destroy();
return 'Data sent Success';
}).catchError((dynamic e) {
return 'Error sending Data';
});
debugPrint(result);
}

I really don't understand what is happening.

Could you advice.

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

1 participant