Print Two Different Text Alignment on same line in Android Bluetooth thermal printer
up vote
0
down vote
favorite
so we are currently developing this app which prints receipts via bluetooth. The process is working, but our only problem is we can't print the layout that we wanted.
We wanted to print in this way:
| ID Number: 123456789|
where the left fields are default, and the right fields are generated automatically.
We tried doing work arounds but it seems like the bluetooth printer only reads one text alignment.
Here's our current code:
align=new byte0x1B, 'a',0x00; \this is left alignment
mmOutputStream.write(align);
mmOutputStream.write(msg.getBytes());
align=new byte0x1B, 'a', 0x02; \this is right alignment
mmOutputStream.write(align);
mmOutputStream.write(msg2.getBytes());
And the output would always be the alignment on top. For example when we set the top alignment on the left. It will just display like this:
| ID Number:123456789 |
I hope you could help us guys, we've been figuring this out about a week.
Thanks! :)
android printing bluetooth alignment
add a comment |
up vote
0
down vote
favorite
so we are currently developing this app which prints receipts via bluetooth. The process is working, but our only problem is we can't print the layout that we wanted.
We wanted to print in this way:
| ID Number: 123456789|
where the left fields are default, and the right fields are generated automatically.
We tried doing work arounds but it seems like the bluetooth printer only reads one text alignment.
Here's our current code:
align=new byte0x1B, 'a',0x00; \this is left alignment
mmOutputStream.write(align);
mmOutputStream.write(msg.getBytes());
align=new byte0x1B, 'a', 0x02; \this is right alignment
mmOutputStream.write(align);
mmOutputStream.write(msg2.getBytes());
And the output would always be the alignment on top. For example when we set the top alignment on the left. It will just display like this:
| ID Number:123456789 |
I hope you could help us guys, we've been figuring this out about a week.
Thanks! :)
android printing bluetooth alignment
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
so we are currently developing this app which prints receipts via bluetooth. The process is working, but our only problem is we can't print the layout that we wanted.
We wanted to print in this way:
| ID Number: 123456789|
where the left fields are default, and the right fields are generated automatically.
We tried doing work arounds but it seems like the bluetooth printer only reads one text alignment.
Here's our current code:
align=new byte0x1B, 'a',0x00; \this is left alignment
mmOutputStream.write(align);
mmOutputStream.write(msg.getBytes());
align=new byte0x1B, 'a', 0x02; \this is right alignment
mmOutputStream.write(align);
mmOutputStream.write(msg2.getBytes());
And the output would always be the alignment on top. For example when we set the top alignment on the left. It will just display like this:
| ID Number:123456789 |
I hope you could help us guys, we've been figuring this out about a week.
Thanks! :)
android printing bluetooth alignment
so we are currently developing this app which prints receipts via bluetooth. The process is working, but our only problem is we can't print the layout that we wanted.
We wanted to print in this way:
| ID Number: 123456789|
where the left fields are default, and the right fields are generated automatically.
We tried doing work arounds but it seems like the bluetooth printer only reads one text alignment.
Here's our current code:
align=new byte0x1B, 'a',0x00; \this is left alignment
mmOutputStream.write(align);
mmOutputStream.write(msg.getBytes());
align=new byte0x1B, 'a', 0x02; \this is right alignment
mmOutputStream.write(align);
mmOutputStream.write(msg2.getBytes());
And the output would always be the alignment on top. For example when we set the top alignment on the left. It will just display like this:
| ID Number:123456789 |
I hope you could help us guys, we've been figuring this out about a week.
Thanks! :)
android printing bluetooth alignment
android printing bluetooth alignment
asked Aug 31 '17 at 3:43
user3060463
116
116
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
I'm resolve that with create function like this:
void writePrint(byte align, String msg)
try
mmOutputStream.write(align);
String space = " ";
int l = msg.length();
if(l < 31)
for(int x = 31-l; x >= 0; x--)
space = space+" ";
msg = msg.replace(" : ", space);
mmOutputStream.write( msg.getBytes());
catch (IOException e)
e.printStackTrace();
And we can use it:
writePrint( PRINT_CENTER, "| ID Number : 123456789 |");
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
I'm resolve that with create function like this:
void writePrint(byte align, String msg)
try
mmOutputStream.write(align);
String space = " ";
int l = msg.length();
if(l < 31)
for(int x = 31-l; x >= 0; x--)
space = space+" ";
msg = msg.replace(" : ", space);
mmOutputStream.write( msg.getBytes());
catch (IOException e)
e.printStackTrace();
And we can use it:
writePrint( PRINT_CENTER, "| ID Number : 123456789 |");
add a comment |
up vote
0
down vote
I'm resolve that with create function like this:
void writePrint(byte align, String msg)
try
mmOutputStream.write(align);
String space = " ";
int l = msg.length();
if(l < 31)
for(int x = 31-l; x >= 0; x--)
space = space+" ";
msg = msg.replace(" : ", space);
mmOutputStream.write( msg.getBytes());
catch (IOException e)
e.printStackTrace();
And we can use it:
writePrint( PRINT_CENTER, "| ID Number : 123456789 |");
add a comment |
up vote
0
down vote
up vote
0
down vote
I'm resolve that with create function like this:
void writePrint(byte align, String msg)
try
mmOutputStream.write(align);
String space = " ";
int l = msg.length();
if(l < 31)
for(int x = 31-l; x >= 0; x--)
space = space+" ";
msg = msg.replace(" : ", space);
mmOutputStream.write( msg.getBytes());
catch (IOException e)
e.printStackTrace();
And we can use it:
writePrint( PRINT_CENTER, "| ID Number : 123456789 |");
I'm resolve that with create function like this:
void writePrint(byte align, String msg)
try
mmOutputStream.write(align);
String space = " ";
int l = msg.length();
if(l < 31)
for(int x = 31-l; x >= 0; x--)
space = space+" ";
msg = msg.replace(" : ", space);
mmOutputStream.write( msg.getBytes());
catch (IOException e)
e.printStackTrace();
And we can use it:
writePrint( PRINT_CENTER, "| ID Number : 123456789 |");
answered Nov 2 '17 at 7:25
Agus Nurwanto
1
1
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f45972890%2fprint-two-different-text-alignment-on-same-line-in-android-bluetooth-thermal-pri%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password