Skip to content

Printer not printing with original code #201

@srochacito

Description

@srochacito

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions