Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two Printables in same line won't dsiplay correct way #100

Open
HIMESH1018 opened this issue Jul 15, 2022 · 2 comments
Open

Two Printables in same line won't dsiplay correct way #100

HIMESH1018 opened this issue Jul 15, 2022 · 2 comments

Comments

@HIMESH1018
Copy link

HIMESH1018 commented Jul 15, 2022

    val printableTotal = TextPrintable.Builder()
        .setText("Total")
        .setAlignment(DefaultPrinter.ALIGNMENT_LEFT)
        .setEmphasizedMode(DefaultPrinter.EMPHASIZED_MODE_NORMAL)
        .build()

    val printableTotalValue = TextPrintable.Builder()
        .setText("20000")
        .setAlignment(DefaultPrinter.ALIGNMENT_RIGHT)
        .setEmphasizedMode(DefaultPrinter.EMPHASIZED_MODE_NORMAL)
        .setLineSpacing(10)
        .setNewLinesAfter(5)
        .build()`

print
")

@HIMESH1018
Copy link
Author

@mazenrashed

@SnapperNewbie
Copy link

SnapperNewbie commented Oct 8, 2022

You have to format your string.
I format my Strings in a method like this
(32 Characters in Line for my Printer)

private String formatForColum (String item, String price) {
float f1 = Float.parseFloat(price);
String formattedPrice = String.format("%.02f", f1); //2 Decimals

String column1Format = "%-24.24s";  // fixed size 24 characters, left aligned
String column2Format = "%7.7s";   // fixed size 7 characters, right aligned
String formatInfo = column1Format + " " + column2Format;

return String.format(formatInfo, item, formattedPrice);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants