Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IPP attributes required by IPP Everywhere for PWG Raster when PWG Raster as input format is supported #4428

Closed
michaelrsweet opened this issue Jun 6, 2014 · 5 comments

Comments

@michaelrsweet
Copy link
Collaborator

@michaelrsweet michaelrsweet commented Jun 6, 2014

Version: 2.2-feature
CUPS.org User: till.kamppeter

The specs for IPP Everywhere (section 5.3 "IPP Printer Description Attributes", page 37) require the following printer IPP attributes to tell clients which types of PWG Raster input files are supported by this printer:

pwg-raster-document-resolution-supported
pwg-raster-document-sheet-back
pwg-raster-document-type-supported

With the attached patch I add these attributes (only if PWG Raster is available as input format, for example with cups-filters 1.0.54 which introduces the rastertopdf filter), so that a print queue shared by a CUPS server completely emulates an IPP Everywhere printer and for example mobile devices or appliances (like digital cameras) supporting IPP Everywhere printers via PWG Raster can print on the shared CUPS queue.

The patch checks at first if PWG Raster is one of the input formats and add the attributes only then. For pwg-raster-document-resolution-supported it copies the arguments of "printer-resolution-supported", for pwg-raster-document-sheet-back it always takes "normal" (the actual sheet back handling is done on the CUPS server) and for pwg-raster-document-type-supported it takes the following:

     "adobergb-8"
     "adobergb-16"
     "black-1"
     "black-8"
     "black-16"
     "cmyk-8"
     "cmyk-16"
     "rgb-8"
     "rgb-16"
     "sgray-1"
     "sgray-8"
     "sgray-16"
     "srgb-8"
     "srgb-16"

These are the formats the rastertopdf filter of cups-filters currently is able to convert.

I have simply made a patch which works, feel free to put it at a different place in the scheduler code or modify it.

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

@michaelrsweet michaelrsweet commented Jun 9, 2014

CUPS.org User: mike

OK, we can't use this patch as-is. Among other things, we should be pulling the values from the PPD file (right now you assume 300/600/1200 DPI, all color spaces, and normal duplexing), otherwise existing raster drivers will simply not work.

Putting this in the 2.1 pile for now, but if I get a chance I'll re-work it for 2.0.

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

@michaelrsweet michaelrsweet commented Jun 9, 2014

CUPS.org User: till.kamppeter

For the resolution I do not simply assume 300/600/1200 DPI, I first check whether there is already a resolution option and if so, I copy the resolutions from it,only if there is no resolution option, I assume 300/600/1200 DPI.

For the back side I always use "normal" as the PWG Raster input always gets turned to PDF by the server and then the further filtering steps (pdftopdf -> gstoraster/pdftoraster -> rasterto...) handle the correct back side orientation for the printer.

Color spaces are also converted by the filter chain on the CUPS server so it is no problem that I accept all color spaces with any printer.

My workflow never passes PWG Raster directly through from the client to the printer, even if the printer understands PWG Raster natively. So CUPS page management (selected pages, mirror, even/odd, N-up, ...) is always supported as all jobs go through pdftopdf and a mobile device sending PWG Raster can print to any non-raw CUPS queue, also if the printer is for example an old LaserJet which only understands PCL or a Samsung using the SpliX driver, like we always could print JPG images on any CUPS queue all the time (and if the printer understands JPG natively the jobs still go through pdftopdf).

As all jobs go through pdftopdf the client does not need to know the fine detail of the actual printer. It gets the resolution to avoid Moiré effects of printing a 600-dpi image on a 720-dpi Epson inkjet, it gets not of the presence of duplex support to allow the user to send duplex jobs, but the client does not need to bother with back side oriantation and the printer's native color spaces as the server takes care of that in the filter chain. So a mobile client device can work with a very simple printing stack.

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

@michaelrsweet michaelrsweet commented Jun 4, 2015

CUPS.org User: mike

Deferring to a later CUPS release.

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

@michaelrsweet michaelrsweet commented Sep 14, 2015

"pwg-raster-attributes.patch":

--- scheduler/printers.c.orig   2014-06-06 20:05:01.400272758 +0200
+++ scheduler/printers.c    2014-06-06 20:04:06.688273606 +0200
@@ -2044,9 +2044,10 @@
   cupsd_location_t *auth;      /* Pointer to authentication element */
   const char   *auth_supported;    /* Authentication supported */
   ipp_t        *oldattrs;      /* Old printer attributes */
-  ipp_attribute_t *attr;       /* Attribute data */
+  ipp_attribute_t *attr, *attr2;   /* Attribute data */
   char     *name,          /* Current user/group name */
        *filter;        /* Current filter */
+  mime_type_t   *type;


   DEBUG_printf(("cupsdSetPrinterAttrs: entering name = %s, type = %x\n", p->name,
@@ -2398,6 +2399,80 @@
   DEBUG_printf(("cupsdSetPrinterAttrs: leaving name = %s, type = %x\n", p->name,
                 p->type));

+  /* 
+   * Add "pwg-raster-document-xxx-supported" attributes if PWG Raster input
+   * is supported
+   */
+  for (type = (mime_type_t *)cupsArrayFirst(p->filetypes);
+       type;
+       type = (mime_type_t *)cupsArrayNext(p->filetypes))
+  {
+    if (!_cups_strcasecmp(type->super, "image"))
+    {
+      if (!_cups_strcasecmp(type->type, "pwg-raster"))
+      {
+   if (p->ppd_attrs != NULL &&
+       (attr = ippFindAttribute(p->ppd_attrs,
+                    "printer-resolution-supported",
+                    IPP_TAG_ZERO)) != NULL)
+   {
+     attr2 = ippAddResolutions(p->attrs, IPP_TAG_PRINTER,
+                   "pwg-raster-document-resolution-supported",
+                   attr->num_values, IPP_RES_PER_INCH,
+                   NULL, NULL);
+     for (i = 0; i < attr->num_values; i ++)
+     {
+       attr2->values[i].resolution.xres =
+         attr->values[i].resolution.xres;
+       attr2->values[i].resolution.yres =
+         attr->values[i].resolution.yres;
+       attr2->values[i].resolution.units = IPP_RES_PER_INCH;
+     }
+   }
+   else
+   {
+     static const int  pwg_raster_document_resolution_supported[] =
+     {
+       300,
+       600,
+       1200
+     };
+     ippAddResolutions(p->attrs, IPP_TAG_PRINTER,
+               "pwg-raster-document-resolution-supported",
+               (int)(sizeof(pwg_raster_document_resolution_supported) /
+                 sizeof(pwg_raster_document_resolution_supported[0])),
+               IPP_RES_PER_INCH,
+               pwg_raster_document_resolution_supported,
+               pwg_raster_document_resolution_supported);
+   }
+   ippAddString(p->attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+            "pwg-raster-document-sheet-back", NULL, "normal");
+   static const char * const pwg_raster_document_type_supported[] =
+   {
+     "adobergb-8",
+     "adobergb-16",
+     "black-1",
+     "black-8",
+     "black-16",
+     "cmyk-8",
+     "cmyk-16",
+     "rgb-8",
+     "rgb-16",
+     "sgray-1",
+     "sgray-8",
+     "sgray-16",
+     "srgb-8",
+     "srgb-16"
+   };
+   ippAddStrings(p->attrs, IPP_TAG_PRINTER, IPP_TAG_KEYWORD,
+             "pwg-raster-document-type-supported",
+             (int)(sizeof(pwg_raster_document_type_supported) /
+               sizeof(pwg_raster_document_type_supported[0])), NULL,
+             pwg_raster_document_type_supported);
+      }
+    }
+  }
+
  /*
   * Add name-default attributes...
   */

@michaelrsweet

This comment has been minimized.

Copy link
Collaborator Author

@michaelrsweet michaelrsweet commented May 16, 2016

[master 71d227b] The scheduler now advertises PWG Raster attributes for IPP Everywhere clients (Issue #4428)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.