title: PrinterJob versus DocPrintJob
body: <p>I need to implement a listener for my printing routine in order to get status from the printer. I am using PrinterJob, but the listener PrintServiceAttributeListener is not sufficient for me. I would like to implement the listener for DocPrintJob instead. How do I convert to DocPrintJob?</p>
  
  <p>Here is my original code:</p>
  
  <pre><code>public void print(int bufWidth, int bufHeight, BufferedImage bufImage, String printerName, String doPrint)
   {
     try
     {
       image = bufImage;
       if (doPrint.toUpperCase().equals("YES"))
       {
         PrinterJob printerJob = getPrinterJob(printerName);
         PrintService printService = printerJob.getPrintService();
         //printService.addPrintServiceAttributeListener(this);
         //printerJob.addPrintJobListener(new PrintJobMonitor());
  
         int width = bufImage.getWidth();
         int height = bufImage.getHeight();
  
         PageFormat pf = printerJob.defaultPage();
         Paper paper = pf.getPaper();
         paper.setSize(width, height);
  
         double imageableX = fromCMToPPI(0.1);
         double imageableY = fromCMToPPI(0.1);
         double imageableWidth = width - fromCMToPPI(0.1);
         double imageableHeight = height - fromCMToPPI(0.1);
         paper.setImageableArea(imageableX, imageableY, imageableWidth, imageableHeight);
  
         pf.setOrientation(PageFormat.LANDSCAPE);
         pf.setPaper(paper);
         PageFormat validatePage = printerJob.validatePage(pf);
  
         printerJob.setPrintable(new MyPrintable(), validatePage);       
         printerJob.print();
       }
     }
     catch (Exception ex)
     {
     }
  }
  </code></pre>