andresperezmelo / print_bluetooth_thermal

Plugin para enviar bytes sin procesar a la impresora solo por ahora para Android
Other
27 stars 36 forks source link

Print not in center #7

Closed ferns-it closed 2 years ago

ferns-it commented 2 years ago

I tested the example package, it is working properly. But when I used in my real project. The text is not print in center. I already changed the "Pos Align: Center". But still not working

ferns-it commented 2 years ago

I used this package "esc_pos_utils_plus: ^2.0.1+3" version. but now the printer only printer center.

andresperezmelo commented 2 years ago

You need to add the PostAlign.center

tested version: esc_pos_utils_plus: ^2.0.1+6

a simple example

CapabilityProfile profile = await CapabilityProfile.load();
    final generator = Generator(PaperSize.mm58, profile);
    List<int> bytes = [];
    bytes += generator.setGlobalFont(PosFontType.fontA);

bytes += generator.text("Bussines", styles: PosStyles(align: PosAlign.center));

try the example and tell me

ferns-it commented 2 years ago

Sorry for the late reply, I tested printing using your sample code. Now, printer is printing on the center but, the problem is I can't able to print align to left or right. Do you have any solutions for this problem ?

My Tested Printer Details : EPSON M335B2

ferns-it commented 2 years ago

Hope you reply me soon

andresperezmelo commented 2 years ago

You can use the same example but use

Letf

bytes += generator.text("Bussines", styles: PosStyles(align: PosAlign.letf));

rigth

bytes += generator.text("Bussines", styles: PosStyles(align: PosAlign.rigth));

You can also use tables, the table must be divided into 12 spaces, each PostColumn -> width

bytes += generator.row([
      PosColumn(
        text: 'Name:',
        width: 8,
        styles: PosStyles(
          align: PosAlign.left,
        ),
      ),
      PosColumn(
        text: "Smits",
        width: 4,
        styles: PosStyles(
          align: PosAlign.left,
        ),
      ),
    ]);
ferns-it commented 2 years ago

I already tried this, but it doesn't work. The printer still print on center itself.

andresperezmelo commented 2 years ago

Try using the last example to use it to align the text

bytes += generator.row([
      PosColumn(
        text: 'Name:',
        width: 8,
        styles: PosStyles(
          align: PosAlign.left,
        ),
      ),
      PosColumn(
        text: "Smits",
        width: 4,
        styles: PosStyles(
          align: PosAlign.left,
        ),
      ),
    ]);