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

Text wrap #13

Closed mic7010 closed 2 years ago

mic7010 commented 3 years ago

How do I control printing descriptions that exceed the label width? Do you support wrapping or other methods?

bandit-ibayashi commented 3 years ago

@mic7010 If the text data is more than the label width, it will automatically be printed on the next line. Each printer has a specific number of characters that can be printed, so please let us know the model name of the printer you want to print.

mic7010 commented 3 years ago

The model is the sm-l300. I did a test with a long description which was not wrapped. Can you provide a code snippet? Also, can I set a max lines to print?

bandit-ibayashi commented 3 years ago

I have printed a 50 character text as shown below and confirmed that it wraps at the 49th character as shown in the picture.

var builder = new StarXpandCommand.StarXpandCommandBuilder();
builder.addDocument(new StarXpandCommand.DocumentBuilder()
    .addPrinter(new StarXpandCommand.PrinterBuilder()
        .actionPrintText("12345678901234567890123456789012345678901234567890\n")
        .actionCut(StarXpandCommand.Printer.CutType.Partial)
    )
);
var commands = await builder.getCommands();

await printer.open();
await printer.print(commands);
bandit-ibayashi commented 3 years ago

Although not in terms of the number of characters, you can also specify the print area in millimeters by settingPrintableArea method.

The following is an example of setting the width to 48mm.

var builder = new StarXpandCommand.StarXpandCommandBuilder();
builder.addDocument(new StarXpandCommand.DocumentBuilder()
    .settingPrintableArea(48)
    .addPrinter(new StarXpandCommand.PrinterBuilder()
        .actionPrintText("12345678901234567890123456789012345678901234567890\n")
        .actionCut(StarXpandCommand.Printer.CutType.Partial)
    )
);
kickbk commented 2 years ago

Setting the width is not at all an answer to this question. It does not help in any way to avoid breaking words. If there is no way to avoid word breaking, please confirm by letting us know there is no way to avoid it. If there's a way, please advise.

gare-bear commented 2 years ago

@kickbk Star printers always break mid character if you exceed the maximum characters per line; they do not word wrap.

All of our printers have two fonts, Font A and Font B. Using Font A, our 3" printers allow for 48 characters per line. Using Font B which is the smaller width font, you can get up to 64 characters per line.

Knowing how many characters per line your printer supports will help you avoid word breaks and any unintentional wrapping.

I'm going to lock this conversation since this issue has been closed for some time. Please open a new issue for your specific use case if you need more help on this topic.