I am creating a ViewPrintJob and sending it to the printer. This is working well for the Flex receipt and the mini receipt. However, the Station is printing it pushed to the right. The code building the view had to be done (per error messages I was receiving) on the UI thread which leads me to believe that this is due to the width being created with the display and I am not sure. Can I get the characteristics of the printer and set my sizing based on reality instead of what I am doing now? I have the view's xml set to match_parent.
Also, printing the receipt takes a couple of seconds to start. Is there a way to speed that up?
LayoutInflater inflater = LayoutInflater.from(CountActivity.this);
Also, printing the receipt takes a couple of seconds to start. Is there a way to speed that up?
LayoutInflater inflater = LayoutInflater.from(CountActivity.this);
final ViewGroup receiptView = (ViewGroup)inflater.inflate(R.layout.receipt_view, null); receiptView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); receiptView.layout(0, 0, receiptView.getMeasuredWidth(), receiptView.getMeasuredHeight()); new AsyncTask<Void, Void, String>() { @Override protected String doInBackground(Void... voids) { try { //View view = findViewById(R.id.rightFrame); Printer p = getPrinter(); PrintJob printJob = new ViewPrintJob.Builder().view(receiptView).build(); return new PrintJobsConnector(CountActivity.this).print(p, printJob); } catch (Exception e) { e.printStackTrace(); } return null; } @Override protected void onPostExecute(String id) { // I need to figure out what if anything goes here if (id == null) { return; } //textId.setText(id); //monitorState(); } }.execute();