I am developing an Point-Of-Sale android application. My Tysso PRP 188 printer is connected by Ethernet. I can print on the printer but i don't know how to cut paper after print is finished.
The String i am using to print is below:
msg = "\n" +
" KOT \n"+
"Voucher No: " + vno + " \t Order No: " + ono + "\n" +
"Waiter Name: " + wname + " \t Table: " + tno + "\n" +
"Time: " + time + " \n" +
"- - - - - - - - - - - - - - - - - - - - - - - -\n" +
" Item Quantity \n" +
"- - - - - - - - - - - - - - - - - - - - - - - -\n" +
"\n" +
itemslist +
"\n- - - - - - - - - - - - - - - - - - - - - - - -\n" +
"\n\n\n\n\n\n\n\n";
and this is how i print it.
private class MyPrinter extends AsyncTask<String, String, String>
{
Socket sock;
PrintWriter oStream;
DataInputStream is;
ProgressDialog pDialog = null;
Context context;
public MyPrinter(Context context)
{
this.context = context;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(CustomerInformation.this);
pDialog.setTitle("Print Order");
pDialog.setMessage("Please Wait ...");
pDialog.show();
}
protected String doInBackground(String... params) {
try
{
sock = new Socket(params[0], Integer.parseInt(params[1]));
sock.setSoTimeout(300);
is = new DataInputStream(sock.getInputStream());
if(sock.getRemoteSocketAddress() != null)
{
oStream = new PrintWriter(sock.getOutputStream());
oStream.println(params[2]);
}
else
{
Log.i("cycle", "Remote Socket Address");
}
oStream.flush();
oStream.close();
sock.close();
}
catch (UnknownHostException e)
{
Log.i("cycle", "00");
e.printStackTrace();
}
catch (IOException e)
{
Log.i("cycle", "11");
e.printStackTrace();
}
finally{
}
return null;
}
@Override
protected void onPostExecute(String result) {
super.onPostExecute(result);
if(pDialog != null)
if(pDialog.isShowing())
pDialog.dismiss();
finish();
}
}
I am not sure but i think to solve my problem i have to convert my Text-to-print in some kind of encoding which this printer understands so how to do it i don't know !!!