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

Can you confirm if there is a problem with accentuation? #136

Open
EwertonDutra opened this issue Mar 27, 2024 · 2 comments
Open

Can you confirm if there is a problem with accentuation? #136

EwertonDutra opened this issue Mar 27, 2024 · 2 comments

Comments

@EwertonDutra
Copy link

Hi,
I am make this code:

Future<String> print(dynamic pedido) async {
    List<int> bytes = [];
    final profile = await _profile;
    final generator = Generator(PaperSize.mm80, profile);

    bytes += [27, 97, 1];
    bytes += generator.text('Pedido #${pedido['id']}', styles: const PosStyles(bold: true, height: PosTextSize.size2));

    bytes += [27, 97, 1];
    bytes += generator.text('Cliente : ${pedido['customer']['user']['name']}');
    bytes += generator.text('Email : ${pedido['customer']['user']['email']}');

    bytes += [27, 97, 1];
    bytes += generator.feed(1);

    bytes += generator.row([
      PosColumn(
        text: 'Quant',
        width: 2,
        styles: const PosStyles(align: PosAlign.left),
      ),
      PosColumn(
        text: 'Item',
        width: 8,
        styles: const PosStyles(align: PosAlign.center),
      ),
      PosColumn(
        text: 'Preco',
        width: 2,
        styles: const PosStyles(align: PosAlign.right),
      ),
    ]);

    for (var item in pedido['products']) {
      bytes += generator.row([
        PosColumn(
          text: item['pivot']['quantity'].toString(),
          width: 2,
          styles: const PosStyles(align: PosAlign.center),
        ),
        PosColumn(
          text: '${item['name']} (${item['description']})',
          width: 8,
          styles: const PosStyles(align: PosAlign.center),
        ),
        PosColumn(
          text: ' ${item['pivot']['subtotal'].toString()}',
          width: 2,
          styles: const PosStyles(align: PosAlign.center),
        ),
      ]);
    }

    bytes += generator.feed(1);
    bytes += [27, 97, 1];
    bytes += generator.text('Total  R\$ ${pedido['total_price']}');

    bytes += [27, 97, 1];
    bytes += generator.text('Data : ${pedido['created_at']}');
    bytes += generator.feed(1);
    bytes += generator.text('*** Obrigado por seu ço pédido ***', styles: const PosStyles(bold: true, height: PosTextSize.size2), containsChinese: true);

    bytes += generator.feed(1);
    bytes += generator.cut();

    final res =
    await usb_esc_printer_windows.sendPrintRequest(bytes, _printerName);
    String msg = "";

    if (res == "success") {
      msg = "Printed Successfully";
    } else {
      msg =
      "Failed to generate a print please make sure to use the correct printer name";
    }

    return msg;
  }

Along these lines, I even tried some settings, but it didn't help.

bytes += generator.text('*** Obrigado por seu ço pédido ***', styles: const PosStyles(bold: true, height: PosTextSize.size2), containsChinese: true);

Thanks

@jsalvini
Copy link

jsalvini commented Sep 9, 2024

It is specified in the documentation how to work with accents

bytes += generator.text('Special 1: àÀ èÈ éÉ ûÛ üÜ çÇ ôÔ',
styles: PosStyles(codeTable: PosCodeTable.westEur));

@EwertonDutra
Copy link
Author

thanks

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