# Problem description Starting with Git commit ea7c47c1bb51d079aff44b88f94b3fe5c76fbce5, when using `java.awt.print.PrinterJob` to print on macOS, the native print dialog's “Open in Preview”, “Send in Mail”, “Save to iCloud Drive”, and “Save to Web Receipts” options no longer do what they say. Instead, choosing any of these options sends a print job to the actual printer. “Save as PDF” and “Save as PostScript” still work correctly. The “Open in Preview” option does work correctly in previous versions of OpenJDK.
# Problem cause The source of this problem is in line 440 of `src/java.desktop/macosx/native/libawt_lwawt/awt/CPrinterJob.m`, which resets the `jobDisposition` of the `NSPrintInfo` to `NSPrintSpoolJob`, overriding the user's prior selection (which might be `NSPrintPreviewJob` or some other value). # Fix The fix is to add an if statement that checks if the job is equal to a NSPrintSaveJob and only than sets the job disposition to a NSPrintSpoolJob. # Tests The test is provided as a manual test which just opens a print window where You are supposed to click on PDF and then "Open in Preview" or one of the other previously mentioned options. - [x] I confirm that I make this contribution in accordance with the [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai). ------------- Commit messages: - Generalized the fix - Fixing printer preview issue Changes: https://git.openjdk.org/jdk/pull/34041/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=34041&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8276027 Stats: 104 lines in 2 files changed: 103 ins; 0 del; 1 mod Patch: https://git.openjdk.org/jdk/pull/34041.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/34041/head:pull/34041 PR: https://git.openjdk.org/jdk/pull/34041
