RFR: 8251928: [macos] the printer DPI always be 72, cause some content lost when print out [v5]

GennadiyKrivoshein duke at openjdk.org
Mon Sep 8 21:56:14 UTC 2025


On Thu, 4 Sep 2025 21:58:50 GMT, Phil Race <prr at openjdk.org> wrote:

>> GennadiyKrivoshein has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   revert CGraphicsDevice.m constants. Update orientation constant usage
>
> src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterJob.java line 470:
> 
>> 468:     @Override
>> 469:     protected double getXRes() {
>> 470:         return hRes;
> 
> I have been unable to verify that this would be applied with a real printer device resolution, because my printer is not reporting PrinterResolution. Not sure why. I see it in the PPD but the call to the cups ppd API isn't finding it.
> Thinking about it, this is may be the "real" problem if something in this API used to work but has stopped working.

I'm able to choose and set resolution for a Zebra Label Printer, its PPD contains

*DefaultResolution: 300dpi
*Resolution 203dpi/203dpi: "<</HWResolution[203 203]/.....>>setpagedevice"
*Resolution 300dpi/300dpi: "<</HWResolution[300 300]/.....>>setpagedevice"
*Resolution 600dpi/600dpi: "<</HWResolution[600 600]/.....>>setpagedevice"

CUPS API returns nothing for Brother DCP-T720, and its PPD contains  _DefaultResolution_ only.

*TTRasterizer: Type42
*DefaultResolution: 300dpi
*FreeVM: "1700000"


I'm sure the reason is the lack of _Resolution_ options. The _DefaultResolution_ attribute is not read in Java_sun_print_CUPSPrinter_getResolutions function. I tried adding a _ppdFindAttr(ppd_file, "DefaultResolution", NULL)_ function call and it returned correct default value.

> src/java.desktop/macosx/classes/sun/lwawt/macosx/CPrinterJob.java line 795:
> 
>> 793:         return scaledPage;
>> 794:     }
>> 795: 
> 
> This is something of an abuse of these APIs which are *specified* to have sizes in 1/72"
> 
> This is all needed here because createData takes a PageFormat.
> I looked and unless I am missing something all it ever does is use the bounds to return those (now larger) device bounds.
> 
> I would consider it a better approach to modify CPrinterSurfaceData.createData to accept what it really needs .. the device bounds. I don't see that it needs a page format.

You absolutely right about the specified size. I moved the changes to the CPrinterGraphicsConfig.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/25489#discussion_r2331457749
PR Review Comment: https://git.openjdk.org/jdk/pull/25489#discussion_r2331463639


More information about the client-libs-dev mailing list