title: How to detect the ‘Save as PDF…’ was picked from an AWT PrinterJob on OS X
body: <p>I have the following code that shows a native print dialog in my java application.</p>
  
  <pre><code>PrinterJob job = PrinterJob.getPrinterJob();
  PrintRequestAttributeSet atts = new HashPrintRequestAttributeSet();
  atts.add(DialogTypeSelection.NATIVE);
  
  if (job.printDialog(atts)) 
  {
      PrintService newlyUsedService = job.getPrintService();
      DocPrintJob docJob = newlyUsedService.createPrintJob();
      // print the passed javax.print.SimpleDoc object.
      docJob.print(simpleDoc, atts);
  }
  </code></pre>
  
  <p>This code works fine when a printer is selected and the Print button is clicked, but it does not work when the user selects any option from the “PDF” menu at the bottom left. The getPrintService method returns the last selected printer (<code>Lillith</code> from the screenshot) when one of the options in the "PDF" menu are selected.</p>
  
  <p><img src="https://i.stack.imgur.com/an4wV.png" alt="Screenshot of OS X print dialog"></p>
  
  <p>Could anyone suggest what should be done to detect when “Save as PDF…” was selected in the print dialog and respond accordingly.</p>