--- old/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterJob.java 2018-09-26 16:58:02.522171999 +0530 +++ new/src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterJob.java 2018-09-26 16:58:01.997910000 +0530 @@ -246,18 +246,23 @@ } } + boolean isPrintToFile = false; + private void setPrintToFile(boolean printToFile) { + isPrintToFile = printToFile; + } + @Override public void print(PrintRequestAttributeSet attributes) throws PrinterException { // NOTE: Some of this code is copied from RasterPrinterJob. - + // this code uses javax.print APIs // this will make it print directly to the printer // this will not work if the user clicks on the "Preview" button // However if the printer is a StreamPrintService, its the right path. PrintService psvc = getPrintService(); - if (psvc == null) { + if (psvc == null && !isPrintToFile) { throw new PrinterException("No print service found."); }