In order to get status on a print job, a print job listener must be added to the print job before it is submitted to the print service. These status changes are common to all print jobs. A print service may support other types of print job status changes and these are delivered through a print job attribute listener rather than a print job listener; see e715 Listening for Print Job Attribute Changes.
// Create the print job
DocPrintJob job = service.createPrintJob();
job.addPrintJobListener(new MyPrintJobListener());
class MyPrintJobListener implements PrintJobListener {
public void printDataTransferCompleted(PrintJobEvent pje) {
// The print data has been transferred to the print service
}
public void printJobCanceled(PrintJobEvent pje) {
// The print job was cancelled
}
public void printJobCompleted(PrintJobEvent pje) {
// The print job was completed
}
public void printJobFailed(PrintJobEvent pje) {
// The print job has failed
}
public void printJobNoMoreEvents(PrintJobEvent pje) {
// No more events will be delivered from this
// print service for this print job.
// This event is fired in cases where the print service
// is not able to determine when the job completes.
}
public void printJobRequiresAttention(PrintJobEvent pje) {
// The print service requires some attention to repair
// some problem. E.g. running out of paper would
// cause this event to be fired.
}
}