RFR: 8315113: Print request Chromaticity.MONOCHROME attribute does not work on macOS
Tres Finocchiaro
duke at openjdk.org
Tue Mar 12 16:32:13 UTC 2024
On Mon, 11 Mar 2024 13:54:02 GMT, Alexander Scherbatiy <alexsch at openjdk.org> wrote:
> The fix provides ability to print Black & White pages on macOS.
>
> Cocoa API has [PMSetColorMode](https://developer.apple.com/documentation/applicationservices/core_printing/1805783-pmsetcolormode) function but it is marked as deprecated and really does nothing.
>
> There is no replacement; this function was included to facilitate porting legacy applications to macOS,
> but it serves no useful purpose.
>
> Dumping `NSPrintInfo` print settings which were set by the native print dialog on macOS shows that the keys and values used for Black & White printing depend on the used printer type.
> For example, the tested
> `HP Color LaserJet MFP M180n` printer uses `ColorModel` key and`Gray` value, and
> `HP Ink Tank 110 series` uses `HPColorMode` key and `grayscale` value.
>
> Printing all `NSPrintInfo` presets shows that they do not contain key/value pairs for Black&White settings.
> This is the code snippet used to print `NSPrintInfo` presets:
>
> PMPrinter pr;
> PMPrintSession printSession = (PMPrintSession)[printInfo PMPrintSession];
> OSStatus status = PMSessionGetCurrentPrinter(printSession, &pr);
> CFArrayRef presetsList = nil;
> status = PMPrinterCopyPresets(pr, &presetsList);
> CFIndex arrayCount = CFArrayGetCount(presetsList);
>
> for (CFIndex index = 0; index < arrayCount; index++) {
> PMPreset preset = (PMPreset)CFArrayGetValueAtIndex(presetsList, index);
> CFStringRef presetName = nil;
> if (PMPresetCopyName(preset, &presetName) == noErr && CFStringGetLength(presetName) > 0) {
> NSLog(@" presetName: '%@'", presetName);
> NSDictionary* dict = nil;
> if (PMPresetGetAttributes(preset, (CFDictionaryRef*)(&dict)) == noErr) {
> // print preset dict
>
>
> The idea of the proposed fix is to store printer dependent key/value pairs in the `<jdk-home>/conf/printer.properties` property file.
>
> The property file has the format:
>
> print-attribute.print-attribute-value.key=value
>
> where `print-attribute` is the java print attribute, `print-attribute-value` is the corresponding attribute value, and `key` and `value` is the key/value pair used by a specific printer.
>
> For example, for `Chromaticity` attribute the property file could look like:
>
> Chromaticity.MONOCHROME.ColorModel=Gray
> Chromaticity.COLOR.ColorModel=CMYK
> Chromaticity.MONOCHROME.HPColorMode=grayscale
> Chromaticity.COLOR.HPColorMode=color
>
> where `Chromaticity.MONOCHROME` key prefix corresponds to `Chromaticity.MONOCHOROME` print attribute constant with (...
> Build changes look good. However, I think there is some kind of movement trying to _remove_ stuff from the conf directory, rather than adding new files there. @AlanBateman might want to chime in on this.
Hi, as a regular JDK user and a stakeholder to this getting fixed, is there any insight as to where they're moving to?
-------------
PR Comment: https://git.openjdk.org/jdk/pull/18195#issuecomment-1992075911
More information about the build-dev
mailing list