Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set font size for bluetooth printing?

I am writing an application which print ticket receipts.
I have some how written the code to print the receipt but the printer either      

prints in very large size fonts or in very small size( not readable) fonts. Can any body provide me the code to set format.

     try {
            //////////this code runs in thread
                    OutputStream os = mBluetoothSocket
                            .getOutputStream();
                    String BILL = "";
                    BILL = BILL
                            + "     *********      ";
                    BILL = BILL+"\n***Invoice No*** \n" +
                            "Muslim Movers\n"
                            +Todays_date+"\n";

                    BILL = BILL + "\n\n";
                    BILL = BILL + "Tickets:" + "      " + String.valueOf(tickets_wanted)+"\n";
                    BILL = BILL + "Price:        "+String.valueOf(Total_Tickets)+"\n"+
                            Selectedroute+"\n";
                    BILL = BILL
                            + "     *********     \n";
                    ////textsize and allignment
                    byte[] format = { 27, 33, 0 };
                    byte[] arrayOfByte1 = { 27, 3, 0 };
                    format[2] = ((byte)(0x10 | arrayOfByte1[2]));
                    format[2] = ((byte) (0x8 | arrayOfByte1[2]));
} catch (Exception e) {
                    Log.e("Main", "Exe ", e);
}
t.start();
like image 662
Waseem Abbas Avatar asked Nov 26 '16 06:11

Waseem Abbas


People also ask

How do I change font size on wireless printer?

Click the Settings icon , click Print, then select a larger printout size in the Scale setting. Change font size: Click the Settings icon , click Options, click Content, then select a larger font size in the Fonts & Colors section.

How do I select font size for printing?

For printed materials, the optimal point size when choosing a font for print is between 10-12 points, however legibility at this size can vary greatly between different typefaces. Always print out your project at 100% size (without scaling) to determine if the font size is legible for your printed project.


1 Answers

Before writing change your printer configuration:

  byte[] cc = new byte[]{0x1B,0x21,0x00};  // 0- normal size text
  byte[] bb = new byte[]{0x1B,0x21,0x08};  // 1- only bold text
  byte[] bb2 = new byte[]{0x1B,0x21,0x20}; // 2- bold with medium text
  byte[] bb3 = new byte[]{0x1B,0x21,0x10}; // 3- bold with large text

  outputStream.write(cc);
  outputStream.write("Your String");
like image 152
Md Imran Choudhury Avatar answered Sep 23 '22 02:09

Md Imran Choudhury