star-micronics / StarPRNT-SDK-Android-Java

StarPRNT SDK for Android including libraries for supporting application development for Star printers.
https://www.star-m.jp/products/s_print/sdk/starprnt_sdk/manual/android_java/en/index.html
Other
15 stars 4 forks source link

Spacing in text for printed receipts #1

Closed muhammadsr closed 3 years ago

muhammadsr commented 3 years ago

Do we have to manually format the receipt and manage the spacing/text? Is there a template that already has a specific format and we can use?

Screen Shot 2021-01-09 at 12 46 48 PM

gare-bear commented 3 years ago

@muhammadsr

In summary, yes you need to manage the text and spacing. Most of the samples in our SDK use pre-formatted blocks of text for easier maintainability but our CommandBuilder has a ton of methods to make your life easier.

One of those methods, appendHorizontalTabPosition, lets you define "columns" so you can format your receipt data. Take a look at the screenshot below for an example.

Two tabs have been defined at position 5, and 24; implicitly we're also using the left edge as a 3rd column which does not need to be defined as a tab position. These values (5, 24) directly relate to the number of characters per line; for 3" printers a maximum of 48 characters per line are allowed.

In between each piece of text, you can see the escape sequence for the tab character. Screen Shot 2021-01-14 at 12 36 41 PM

muhammadsr commented 3 years ago

That was very helpful. Thank you for that info @gare-bear