Bryanne Vega avatar image
Bryanne Vega asked sam Deactivated edited

Know When Receipt Print Is Done

We're printing some receipts on our devices & we would like to know if I call TextPrintJob or ReceiptPrintJob is there a way to know when the receipt was successfully printed (or if something happened).
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

sam avatar image
sam Deactivated answered sam Deactivated edited
You can use PrintJobConnector to print and grab the printId and reconcile the print with the list of PrintJobContracts:
public void PrintSomething(View view){
new AsyncTask<Void, Void, Order>() {
String order_id = "6EAJX1Y29K076";
Order o = null;
Printer printer = null;
PrinterConnector pc = new PrinterConnector(mContext, mAccount, null);
PrintJobsConnector pjc = new PrintJobsConnector(getBaseContext());

@Overrideprotected Order doInBackground(Void... voids) {
try {
o = mOrderConnector.getOrder(order_id);
printer = pc.getPrinters().get(0);
} catch (Exception e) {
return o;

@Overrideprotected void onPostExecute(Order order) {

if(order != null) {
pj = new StaticPaymentPrintJob.Builder().order(order).build();
String printid = pjc.print(printer, pj);
if (pjc.getPrintJobIds(PrintJobsContract.STATE_DONE).contains(printid)){

Different states you can reference are: STATE_... DONE, PRINTING, IN_QUEUE, ERROR,
1 comment
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Dan avatar image Dan ♦ commented ·

Can also use PrintJobsConnector#getState(String printJobId) to check the state of a specific print job (rather than getting all print jobs for a given state and then checking if your id is in that state).

PrintJobConnector#print(Printer printer, PrintJob printJob) will queue a print job and the return the printJobId.

The print jobs are also trimmed, so depending on the frequency the merchant prints at, the print job will eventually be trimmed and calls to getState will return null.

0 Likes 0 ·

Welcome to the
Clover Developer Community