0

我在这个应用程序中创建了一个适用于 android 的应用程序我连接到 bixolon(350plusll) 打印机,当我的字符串是英文时我打印一张票没问题,我的票打印好但是当我的字符串是波斯语时我的结果打印不正常我的角色是颠倒的,不正确

我用截图没问题,但速度很慢而且不合逻辑

请帮我解决这个问题

多谢

在此处输入图像描述

这是我的代码

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();
    }
}

new2.txt 的内容是底部文本

اما جدیدترین شاهکار سازمان لیگ و هیات فوتبال استان تهران که از سوی همین سازمان لیگ به عنوان برترین هیات ایران انتخاب شد، جانمایی توپ شروع مسابقه روی قیف(یا کنز) بود که در دیدار سایپا و پیکان صورت گرفت.

4

1 回答 1

0

您可以使用 Bixolon 打印机可用的波斯语选项之一,例如以下选项之一:

// Farsi option : Mixed
MainActivity.mBixolonPrinter.setFarsiOption(BixolonPrinter.OPT_REORDER_FARSI_MIXED);

// Farsi option : Right to Left
MainActivity.mBixolonPrinter.setFarsiOption(BixolonPrinter.OPT_REORDER_FARSI_RTL);
于 2019-12-16T10:11:38.260 回答