I create an app for android in this app i connect to a bixolon(350plusll) printer and i print a tiket when my String is in english it is ok and my tiket print good but when my String is in persian my result print is not ok and my characters is revers and not correct
i use screenshot it was ok but it was very slow and not logiacal
please help me for resolve this problem
thanks alot
this is my code
package com.example.bahram.myapplication;
import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.Button;
import com.bixolon.printer.BixolonPrinter;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
public class PrintTicketActivity extends Activity {
Button btn;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_print_tiket);
btn= findViewById(R.id.button);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//I set code page of the printer here because i want the printer print persian so i set that on Farsi
MainActivity.mBixolonPrinter.setSingleByteFont(BixolonPrinter.CODE_PAGE_FARSI);
//i have a file it's name is new2.txt and readContentOfFile is a method which read all of text in new2.txt and at last print data on the paper
MainActivity.mBixolonPrinter.printText(readContentOfFile(),BixolonPrinter.ALIGNMENT_CENTER,BixolonPrinter.TEXT_ATTRIBUTE_FONT_A,BixolonPrinter.TEXT_SIZE_HORIZONTAL1,true);
}
});
}
//read all of the text in new2.txt and return text
String readContentOfFile() {
StringBuilder text = new StringBuilder();
InputStream inputStream = getResources().openRawResource(R.raw.new2);
try {
BufferedReader br = new BufferedReader(new InputStreamReader(inputStream));
String line;
while ((line = br.readLine()) != null) {
text.append(line);
text.append('\n');
}
br.close();
} catch (IOException e) {
//You'll need to add proper error handling here
}
return text.toString();
}
}
content of new2.txt is bottom text
اما جدیدترین شاهکار سازمان لیگ و هیات فوتبال استان تهران که از سوی همین سازمان لیگ به عنوان برترین هیات ایران انتخاب شد، جانمایی توپ شروع مسابقه روی قیف(یا کنز) بود که در دیدار سایپا و پیکان صورت گرفت.
You can use one of the Farsi options available for the Bixolon printer, for example one of the following: