Skip to content

Honor black_1-only PWG Raster printers in driverless queues - #1840

Draft
zayigo wants to merge 1 commit into
OpenPrinting:masterfrom
zayigo:fix/driverless-black1-pwg
Draft

zayigo wants to merge 1 commit into
OpenPrinting:masterfrom
zayigo:fix/driverless-black1-pwg

Conversation

@zayigo

@zayigo zayigo commented Dec 1, 2026 •

Copy link
Copy Markdown

A driverless queue can send 8-bit grayscale PWG Raster to a printer that lists only black_1 in pwg-raster-document-type-supported. This is reproducible with an ordinary PDF job and cups-filters 1.28.17. The generated B&W preset selects Gray even though the only PPD choice is FastGray. Correcting that preset alone still produces 8-bit output because the filter gives print-color-mode=monochrome precedence over ColorModel.

Keep the job's color mode and pass pwg-raster-document-type=black_1 to the filters when the final format is PWG Raster and the driverless PPD offers only packed black. The PPD cache records this constraint and can derive it from a previously generated PPD. New PPDs use the selected PWG format's color capabilities and reference the available black choice in the default and B&W presets.

Reproduction

  1. Advertise image/pwg-raster as the PDF job's only usable output format, with pwg-raster-document-type-supported=black_1 and a correctly typed pwg-raster-document-resolution-supported.
  2. Create a queue with lpadmin -p repro -E -v ipp://PRINTER/ipp/print -m everywhere, then submit lp -d repro example.pdf with the queue defaults.
  3. Inspect the received PWG page header. On parent 9e5f4e2b it reports 8 bits per pixel and color space 18. With this change it reports 1 bit per pixel and color space 3. Adjacent builds of 98ac865 and its parent traced the change in default behavior to that commit.

Verification

  • Built the parent and patched CUPS on Debian with the same cups-filters 1.28.17 and Ghostscript 10.05.1. Submitted 12 jobs per build to an IPP printer running in QEMU and compared guest-side IPP payloads, decoded headers and engine pages.
  • Default black-only, explicit monochrome, printer-default monochrome, an older generated PPD, and a leftover URF capability without the URF MIME type all produced 1-bit black. All ten decoded pages of a multipage black-only job matched the engine's pixel hashes.
  • Mixed-depth and grayscale-only defaults produced 8-bit PWG on both builds. Explicit bi-level on a mixed queue produced 1-bit PWG on both. Both PDF-capable controls received PDF.
  • Added regression coverage to cups/testppd for generated defaults, B&W presets, and PPD cache round trips for black-only and mixed-depth printers.
  • The full upstream make test suite passed on Debian 13.7 (GnuTLS) and macOS (OpenSSL), including the scheduler restart and job history tests.

Keep the monochrome job intent while passing the sole supported PWG encoding to the raster filter. Derive the constraint from the generated ColorModel choices so it also applies to existing PPDs after the cache is rebuilt.
@michaelrsweet michaelrsweet self-assigned this Dec 1, 2026

@michaelrsweet michaelrsweet left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not ready for merging.

Please do not add new, unprefixed PPD keywords. Even if we wanted a "PWG black" keyword (we don't), it would need a "cups" vendor prefix.

AirPrint support (URF/Apple Raster, urf-supported) is far more reliable than IPP Everywhere in this case. If a printer only supports IPP Everywhere and the black_1 raster type, then the corresponding ColorModel PS code for the Gray choice needs to set the corresponding cupsColorSpace value that will go in the PWG Raster header. And that will tell the rasterizer filter which color space to use for grayscale (not just the name).

Printers that only support raster data will only ever use the raster path. If the printer supports both raster and PDF, there is a cupsd_job_t member that remembers whether we need to print a job as raster - the presence of PWG Raster support for the black_1 type is not an indicator that all jobs must be printed as B&W raster.

Comment thread cups/ppd-cache.c
{
pc->product = strdup(value);
}
else if (!_cups_strcasecmp(line, "PWGBlackOnly"))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No.

Comment thread cups/ppd-cache.c
* Product, cupsFilter, cupsFilter2, and cupsPreFilter...
*/

if (pc->pwg_black_only)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No.

Comment thread cups/ppd-cache.c
defattr = ippFindAttribute(supported, "output-mode-default", IPP_TAG_KEYWORD);

if ((attr = ippFindAttribute(supported, "urf-supported", IPP_TAG_KEYWORD)) == NULL)
if (is_pwg)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is fairly good experience that AirPrint (and URF/Apple Raster) is a more reliable target than IPP Everywhere since many early IPP Everywhere printers incorrectly implemented PWG Raster support.

Comment thread cups/ppd-cache.c
}
}

if (black_only)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the printer only supports black_1 then that is the cupsColorSpace that should be chosen for the "Gray" ColorSpace. If both sgray_8 and black_1 are supported then you'll have "Gray" mapped to sgray_8 and "FastGray" mapped to black_1.

Comment thread cups/ppd-cache.c
" com.apple.print.preset.output-mode monochrome\"\n"
"*End\n");
cupsFilePuts(fp,
"*End\n", black_only ? "FastGray" : "Gray");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto. Don't base the default color space on the presence of black_1.

Comment thread cups/ppd-private.h
char *product; /* Product value */
cups_array_t *filters, /* cupsFilter/cupsFilter2 values */
*prefilters; /* cupsPreFilter values */
bool pwg_black_only; /* Only PWG ColorModel is one-bit black */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No.

Comment thread cups/testppd.c
*/

static int do_ppd_tests(const char *filename, int num_options, cups_option_t *options);
static int do_pwg_black_tests(void);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't add more unit tests for PPD files. This is legacy, end-of-life code...

Comment thread scheduler/job.c
static void finalize_job(cupsd_job_t *job, int set_job_state);
static void free_job_history(cupsd_job_t *job);
static char *get_options(cupsd_job_t *job, int banner_page, char *copies,
static char *get_options(cupsd_job_t *job, int banner_page, int pwg_raster, char *copies,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No.

@michaelrsweet michaelrsweet added the investigating Investigating the issue label Dec 1, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

investigating Investigating the issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants