RFR: 8318023: Implement IPP output-bin attribute extension on macOS [v3]
Alexander Scherbatiy
alexsch at openjdk.org
Thu Dec 7 12:36:35 UTC 2023
On Wed, 18 Oct 2023 17:36:49 GMT, Alexander Scherbatiy <alexsch at openjdk.org> wrote:
>> The fix adds new public `OutputBin` print attribute class which allow to set a printer output bin in a `PrinterJob` class. The corresponding internal `CustomOutputBin` class is added as well.
>>
>> - Constants used in `OutputBin` class are based on [Internet Printing Protocol (IPP): “output-bin” attribute extension](https://ftp.pwg.org/pub/pwg/candidates/cs-ippoutputbin10-20010207-5100.2.pdf) document.
>> - `CUPSPrinter.getOutputBins(String printer)` method uses PPD `ppdFindOption(..., "OutputBin")` function to get supported output bins for the given printer on native level.
>> - The fix propagates the `OutputBin` attribute from the printer job attributes to `NSPrintInfo` print settings with `OutputBin` key on macOS.
>>
>> The fix was tested on `Kyocera ECOSYS M8130cidn` printer where `ppdFindOption(..., "OutputBin")` call returns 4 output bins (text, choice):
>> - Printer settings, None
>> - Inner tray, INNERTRAY
>> - Separator tray, SEPARATORTRAY
>> - Finisher (face-down), Main
>>
>> if `Printer settings`, `Inner tray`, or `Finisher (face-down)` CustomOutputBins is set to `PrinterJob.print(...)` attributes a test page is printed to the Main tray of the `Kyocera ECOSYS M8130cidn` printer. If `Separator tray` is used a page is printed to the Separator tray. This is consistent with the printer behavior when a native print dialog is used from a native Preview app to print a document on macOS.
>
> Alexander Scherbatiy has updated the pull request incrementally with three additional commits since the last revision:
>
> - Add empty lines between OutputBin constants
> - Add Override annotation to OutputBin and CustomOutputBin methods
> - Update OutputBin IPP Compatibility description
This is some investigation which I did for output bin attribute extension support on Linux.
[PostScript Language Reference](https://www.adobe.com/jp/print/postscript/pdfs/PLRM.pdf) manual third edition defines `OutputType` page device parameter with type `string` which represents special attributes of the output destination.
The example of `OutputType` usage I have found in [CUPS PPD Extensions](https://www.cups.org/doc/spec-ppd.html).
`OutputType` specifies the output type name, for example:
<</OutputType (Photo)>>setpagedevice
This is my implementation of adding `OutputType` parameter in PSPrinterJob: https://github.com/AlexanderScherbatiy/jdk/commit/92ce5b9e23e0338c0d1b49a653dbc67e0512bdc4
protected void startDoc() throws PrinterException {
...
String outputBin = getOutputBinValue(outputBinAttr);
if (outputBin != null) {
mPSStream.print(" /OutputType (" + outputBin + ") ");
}
I tested it with Kyocera ECOSYS M8130cidn printer using Ubuntu 20.04.1 LTS.
The `ppdFindOption(ppd, "OutputBin")` function from `CUPSfuncs` returns two output bins for the Kyocera ECOSYS M8130cidn:
text: Top, choice: Top
text: Stacker 1, choice: Stacker1
```
The result was that a page is printed to the same output tray (Top) no matter `Top` or `Stacker1` output bin is used for `OutputType` post script parameter.
First, I checked that printing a pdf file from the Unix PDF Viewer app using the system print dialog and choosing different output trays really prints pages to different output trays.
Second, I copied post script files sent by java program for printing from `/var/spool/cups` directory.
The post script file for `Top` output bin contains:
%!PS-Adobe-3.0
...
%%BeginSetup
<< /PageSize [595.2755737304688 841.8897705078125] /DeferredMediaSelection true /ImagingBBox null /ManualFeed false /NumCopies 1 /OutputType (Top) >> setpagedevice
%%EndSetup
which `/OutputType (Top)` setting looks correct.
And for the `Stacker1` output bin:
%%BeginSetup
<< /PageSize [595.2755737304688 841.8897705078125] /DeferredMediaSelection true /ImagingBBox null /ManualFeed false /NumCopies 1 /OutputType (Stacker1) >> setpagedevice
%%EndSetup
the setting for output bin is `/OutputType (Stacker1)`.
The file which sends the PDF Viewer for printing includes `%PDF-1.5` version and I was not able to find the parameter corresponding to the selected output bin even if I convert the file from pdf to ps format using `pdf2ps` tool which generates file in `%!PS-Adobe-3.0` fromat.
It is not clear for me why `/OutputType (Stacker1)` parameter does not work and is there a way to take the output bin parameter which Linux native printer dialog use to print a document to the `Stacker 1` tray for the Kyocera ECOSYS M8130cidn printer.
One more question which I have relates to the java common print dialog. It needs to contain list of available output bins. Is it safe to assume that the first output bin retrieved by `ppdFindOption(ppd, "OutputBin")` is the default one? Or should there be added one more `Default` option for the default output bin selection?
-------------
PR Comment: https://git.openjdk.org/jdk/pull/16166#issuecomment-1845265619
More information about the client-libs-dev
mailing list