Try to understand and do more experiments by experiments.
I have wasted rolls and rolls of thermal paper by printing gibberish.
Money wasted but I get solution by sacrificing, not free.
The above code module utilize java inline code to print using javax.print
The important methods are:
1. printString - pass value in raw String and it should print as it-is
2. printBytes - pass value in byte characters as command according to printer documentation
Do you see the code for cut?
Dim by() As Byte = jo.RunMethodjo("cut", Null)
jo.RunMethod("printBytes", Array(printerGen, by))
The above is how B4X call the inline Java code.
Check or trace back the Java code, in this case "cut".
public byte[] cut() {
byte[] cutP = new byte[] { 0x1d, 'V', 1 };
return cutP;
}
{ 0x1d, 'V', 1 } meaning you need to pass a command (which is a combination of these 3 characters) and converted it to byte array.
This value is to passed to the printBytes and send to the printer to ask it to cut the paper after printing something.
When you want to "alter" the output, such as changing the font size, you need to pass another combination depending on the printer. Maybe another 3 or 4 characters. You may need to find the ASCII/decimal/hex table for the equivalent values.
Next, pass the text to print such as "Invoice".
When you want to exit this font size or reset to normal font size, you need to issue another combination.
This is similar if you want to align the text to left, center or right.
e.g:
Dim size As Int = 1
Dim data As String = Chr(27) & "M" & Chr(Bit.And(1, size)) ' Chr(27) = ESC
jo.RunMethod("printString", Array(printerGen, data))