我正在使用便携式打印机打印收据。我对此不太了解...
这是格式。
如何格式化“ Header 1”字体大小,使其比其他字体大,并且还将所有标题设置在中间?
这是代码
SQLiteDatabase db = mSQLiteHelper.getReadableDatabase();
Cursor cursor = db.rawQuery("select * from Information", null);
while (cursor.moveToNext()) {
txn = new SettingModel();
String header1 = (cursor.getString(cursor.getColumnIndex("header1")));
String header2 = (cursor.getString(cursor.getColumnIndex("header2")));
String header3 = (cursor.getString(cursor.getColumnIndex("header3")));
String header4 = (cursor.getString(cursor.getColumnIndex("header4")));
String txnNo = "TxnNo: " + D_Txn.getText().toString();
String name = "Name: " + D_Name.getText().toString();
String amount = "Amount: " + D_Amount.getText().toString();
String Date = "Date: " + Select_Date.getText().toString();
String Users = (cursor.getString(cursor.getColumnIndex("personInCharge")));
String space = "";
header1 += "\n";
header2 += "\n";
header3 += "\n";
header4 += "\n";
txnNo += "\n";
name += "\n";
amount += "\n";
Date += "\n";
Users += "\n";
space += "\n";
outputStream.write(header1.getBytes());
outputStream.write(header2.getBytes());
outputStream.write(header3.getBytes());
outputStream.write(header4.getBytes());
outputStream.write(txnNo.getBytes());
outputStream.write(name.getBytes());
outputStream.write(amount.getBytes());
outputStream.write(Date.getBytes());
outputStream.write(Users.getBytes());
outputStream.write(space.getBytes());
outputStream.write(space.getBytes());
Toast.makeText(this, "Printing Text...", Toast.LENGTH_SHORT).show();
总有空吗?我使用的是空字符串,对吗?
答案 0 :(得分:1)
....将所有标头设置在中间吗?
要将文本设置为居中,请使用此
byte[] center = new byte[]{0x1B, 'a', 0x01};
然后使用outputStream
outputStream.write(center);
outputStream.write(header1.getBytes());
...