RFR: 8373239: Test java/awt/print/PrinterJob/PageRanges.java fails with incorrect selection of printed pages
Phil Race
prr at openjdk.org
Tue Jan 20 22:52:21 UTC 2026
On Tue, 20 Jan 2026 09:11:06 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:
> If same `PrinterJob `is reused to first print user-set `PageRange `pages and then print ALL pages, it prints the first print job correctly as the page range is set but 2nd job doesn't print ALL pages and reprint the same page range as `from` and `to` page are not reset and reused
>
> Fix is made to check if page range is not set then print all pages
src/java.desktop/windows/classes/sun/awt/windows/WPrinterJob.java line 1737:
> 1735: setPageRange(from, to);
> 1736: } else {
> 1737: attributes.add(new PageRanges(1, 9999));
Win32PrintService uses
new PageRanges(1, Integer.MAX_VALUE);
But in this case, don't you just want to remove the attribute (?) if it exists that is.
src/java.desktop/windows/classes/sun/awt/windows/WPrinterJob.java line 1738:
> 1736: } else {
> 1737: attributes.add(new PageRanges(1, 9999));
> 1738: setPageRange(1, 9999);
If you want to clear this, I think it should be
setPageRange(Pageable.UNKNOWN_NUMBER_OF_PAGES, Pageable.UNKNOWN_NUMBER_OF_PAGES)
those are the initial values set in RasterPrinterJob.
Basically you want to re-set things to exactly as if PageRanges were never set.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/29312#discussion_r2710315794
PR Review Comment: https://git.openjdk.org/jdk/pull/29312#discussion_r2710345208
More information about the client-libs-dev
mailing list