I am sending the text to the bluetooth printer via my android cell. Both the printer and my device are connected via the bluetooth. It\'s Working fine and I
Hi you write on my answer of the same theme this:
I have already asked the same question in this thread HERE, but didnt yet got any response. Got only one answer but it was not helped me.
Let see whether it help you. HERE
If you have done with it then please answer me in my thread. I will definitely appreciate you.
Now I konw how to do it, i had to apply reverse ingeneering and decompile an .apk from the market, using dex2jar on linux and next opening jar with java decompiler... Try this... when u write this command:
out.write(str.getBytes(),0,str.getBytes().length);
U are sending to the method an byte[] array, u can modify format sending another byte[] array before send the real byte[] array...
The default format byte[] array is this:
byte[] arrayOfByte1 = { 27, 33, 0 };
So u can try this:
byte[] format = { 27, 33, 0 };
out.write(format);
out.write(str.getBytes(),0,str.getBytes().length);
These lines i'll print u the default format text, but uf u do it:
byte[] format = { 27, 33, 0 };
format[2] = ((byte)(0x8 | arrayOfByte1[2]));
out.write(format);
out.write(str.getBytes(),0,str.getBytes().length);
It will print text in bold style... U can try this oter format arrays:
// Bold
format[2] = ((byte)(0x8 | arrayOfByte1[2]));
// Height
format[2] = ((byte)(0x10 | arrayOfByte1[2]));
// Width
format[2] = ((byte) (0x20 | arrayOfByte1[2]));
// Underline
format[2] = ((byte)(0x80 | arrayOfByte1[2]));
// Small
format[2] = ((byte)(0x1 | arrayOfByte1[2]));
Too u can combine it, then if u like little and bold text, uncomment these array asignements, for example:
byte[] format = { 27, 33, 0 };
// Bold
format[2] = ((byte)(0x8 | arrayOfByte1[2]));
// Height
format[2] = ((byte)(0x10 | arrayOfByte1[2]));
// Width
format[2] = ((byte) (0x20 | arrayOfByte1[2]));
// Underline
// format[2] = ((byte)(0x80 | arrayOfByte1[2]));
// Small
// format[2] = ((byte)(0x1 | arrayOfByte1[2]));
out.write(format);
out.write(str.getBytes(),0,str.getBytes().length);
This last code prints que biggest text size... I hope this can helps u...
Pdta: sorry for my english
Pdta2: I'm trying to print images, u know how??
I am not sure, but you may be able to achieve this with the Java span
method for setting up font style.
Try something like this:
int start=editbox.getSelectionStart();
int end=editbox.getSelectionEnd();
Spannable span=(Spannable)editbox.getText();
StyleSpan f = new StyleSpan(
Typeface.createFromAsset(getAssets(),
"fonts/genbkbasr.ttf"));
span.setSpan(f, start,end, 0);
Similarly, you can apply font style, font color etc...
For more detail check these:
Android Development: How To Replace Part of an EditText with a Spannable
How to use SpannableString with Regex in android?