JDK-8297191 : [macos] printing page range "page 2 to 2" or "page 2 to 4" on macOS leads to not print
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 8,11,17
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: os_x
  • CPU: generic
  • Submitted: 2022-11-14
  • Updated: 2025-08-08
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Duplicate :  
Description
ADDITIONAL SYSTEM INFORMATION :
Java Version 17.0.5+8, macOS 12.6.1

A DESCRIPTION OF THE PROBLEM :
When on macOS you select a multi page document for printing, for example print "page 2 to 2" or "page 2 to 4,  leads to not printing the selected pages at all. This happens as well as printing from swing and also when printing from Java FX.

The error is located in the file java.desktop/macosx/native/libawt_lawt/awt/CPrinterJob.m on the tag jdk-17+35 in line 615:
jobject page = (*env)->CallObjectMethod(env, jthis, jm_getPageFormat, 0); // AWT_THREADING Safe (!appKit)

Instead there must be written:
jobject page = (*env)->CallObjectMethod(env, jthis, jm_getPageFormat, firstPage); // AWT_THREADING Safe (!appKit)

to fix the error.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Print a multi page document from swing or Java FX and select in the printing dialog a page range from "page 2 to 2".

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Page 2 from the multi page document is printed.
ACTUAL -
  The selected page is not printed (empty page instead).

FREQUENCY : always



Comments
A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/11266 Date: 2022-11-21 14:32:50 +0000
16-07-2025

Issue only occurs on macOS. To reproduce the issue on macOS. Start PageRanges.class from test/jdk/java/awt/print/PrinterJob/PageRanges.java and choose print page range 2-3. The App also works as a standalone. What happens: On macOS only page 3 is printed. What should happen: On macOS page 2 and page 3 is printed.
16-07-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/19740 Date: 2024-06-17 05:54:37 +0000
09-07-2024

Issue reproduced on Mac OS, following are my findings 1. From 2nd page onward Same page as range not printing anything(example 2-2,3-3 etc) 2. From 2nd page onward wrong page printing for range values.
28-05-2024

As mentioned in the title, the issue is only happening on MacOS.
29-11-2022

Checked with attached testcase in Windows 10, issue is not reproducible, Test Result ========= 8u351: Pass 11.0.17: Pass 17.0.5: Pass 19.0.1 Pass 20ea27: Pass Reviewing the incident in MacOS
21-11-2022