I have the following code that shows my own print dialog in my java application.
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); }
This code works great when choosing a printer and clicking the "Print" button, but it does not work when the user selects any option from the "PDF" menu in the lower left corner. The getPrintService method returns the last printer selected ( Lillith from the screenshot) when one of the options in the "PDF" menu is selected.

Can anyone suggest what needs to be done in order to detect when “Save as PDF ...” was selected in the print dialog and respond accordingly.
Abhinay K Reddyreddy
source share