star-micronics / react-native-star-io10

react-native-star-io10 is a library for supporting application development for Star Micronics devices.
Other
88 stars 54 forks source link

Centering the QR code #9

Closed pedromcunha closed 3 years ago

pedromcunha commented 3 years ago

Is there any way to center the QR code? My print command looks like this:

printerBuilder.actionPrintQRCode(
                        new StarXpandCommand.Printer.QRCodeParameter("https://google.com")
                                                          .setModel(
                                StarXpandCommand.Printer.QRCodeModel.Model2
                            )
                            .setLevel(StarXpandCommand.Printer.QRCodeLevel.M)
                            .setCellSize(8)
                    )
gare-bear commented 3 years ago

@pedromcunha if you use styleAlignment just before the QR Code it should center it.

var builder = new StarXpandCommand.StarXpandCommandBuilder();
            builder.addDocument(new StarXpandCommand.DocumentBuilder()
            .addPrinter(new StarXpandCommand.PrinterBuilder()
                .styleAlignment(StarXpandCommand.Printer.Alignment.Center)
                .actionPrintQRCode(new StarXpandCommand.Printer.QRCodeParameter("https://google.com")
                                    .setModel(StarXpandCommand.Printer.QRCodeModel.Model2)
                                    .setLevel(StarXpandCommand.Printer.QRCodeLevel.M)
                                    .setCellSize(8))

The only exception to this rule would be for the TSP100III series since they do not support Alignment.

pedromcunha commented 3 years ago

Ok, great. I'll do that, it shouldn't crash if I try to set the styleAlignment for the TSP100III right? Worst case scenario is that it just doesn't center it, right?

gare-bear commented 3 years ago

Exactly; if the printer doesn't support a command it will just ignore it. The app definitely will not crash.

pedromcunha commented 3 years ago

Amazing, thank you!