On Wed, 26 Jun 2024 20:30:55 GMT, Alisen Chung <ach...@openjdk.org> wrote:
> > Yes, there is some disconnect. For all OS (MAC with above changes) print > > range is working properly only with following values firstPage =0 and > > lastPage =-1 at **RasterPrinterJob.java** and highly depend on > > **pageRangesAttr** . I don't think there is any issue with native code, > > with this change I have brought MAC same as other OS. > > Shouldn't the solution then be to fix the issue with RasterPrinterJob.java > not working properly with correct firstPage and lastPage values? The first question to answer here is whether the page range is set and preserved in the print job attributes. I haven't looked into it, but I presume this is the case. The page range could be handled on the Java level, it may not be passed to the native level at all. What I mean is that JDK uses the page range to print the specified pages. The implementation on macOS could be adjusted in a similar way, as I said in [my previous comment](https://github.com/openjdk/jdk/pull/19740#issuecomment-2183359828). It should be possible to print a range of pages (which can consist of several intervals) without displaying the Print dialog, thus the `PageRanges` should be handled. As far as I understand, the `SunPageSelection.RANGE` attribute is somewhat informational, and specifies that `PageRanges` attribute is set. > It also looks like the indices are different between macOS and java. Perhaps > there's code somewhere that should have but hasn't converted the indices over? It's true. Different classes use different indices. The intervals in `PageRanges` count pages from 1 whereas `PrinterJob` uses 0-based indexing. According to Apple documentation, [`knowsPageRange`](https://developer.apple.com/documentation/appkit/nsview/1483774-knowspagerange?language=objc) returns `YES` if the range is known, in which case the [NSRange](https://developer.apple.com/documentation/foundation/nsrange?language=objc#4292523) structure contains the range of pages, and the pages start from 1. ------------- PR Comment: https://git.openjdk.org/jdk/pull/19740#issuecomment-2194389772