brasizza / sunmi_printer

BSD 3-Clause "New" or "Revised" License
39 stars 46 forks source link

Can't align qrcode in center of paper #20

Closed sergiotucano closed 2 years ago

sergiotucano commented 2 years ago

Hey, Marcus !

I'm using your package and you've doing a great job!

But , when I try print a QR-Code in center of paper, in a Sunmi TS2, the QR-CODE are printed in the left of paper...

I tried:

await SunmiPrinter.setAlignment(SunmiPrintAlign.CENTER);
await SunmiPrinter.printQRCode('myqrcodestring', size:3, errorLevel: SunmiQrcodeLevel.LEVEL_M); 

But don't worked.

Best Regards!

brasizza commented 2 years ago

1 - you can try to clone this repository and run the example page to see if the TICKET will print the qrcode in the center 2 - you can do a custom escpos command with

bytes += generator.rawBytes([27, 97, 49]); // to center bytes += generator.rawBytes([27, 97, 48]); // back to default

you can use the printRaw function

sergiotucano commented 2 years ago

So I find the best way to work with T2s.

Before print QrCode or BarCode , close transaction(submit and exit), init transaction again and print. After print, again, close transaction and init transaction.

In this way the setAlignment work's fine.

brasizza commented 2 years ago

So I find the best way to work with T2s.

Before print QrCode or BarCode , close transaction(submit and exit), init transaction again and print. After print, again, close transaction and init transaction.

In this way the setAlignment work's fine.

That´s a good approach! I think the qrcode just print in some align and to do that i think will work. Thanks for your reply!