Without this getting submitted to cups.org, it will never see the
light of day beyond Ubuntu and Debian...
We'll still have concerns about performance, and will run this patch
through a LOT of testing before it goes in. In particular,
BeginFeature won't give you the right values for custom options, and
you also don't want to override job-level options with things like
"the first page is printed from the envelope feeder" - ideally that
would mean we'd stop at the first page and only consider DocumentSetup
options for extraction.
Anyways, please *do* post this as a feature request on cups.org so we
can get some form of this incorporated into CUPS 1.5, but using the
already-supported-for-a-long-time cupsJobTicket comments is the
recommended path since it is also the only way we current support job
tickets for PDF files.
On Aug 28, 2009, at 11:31 AM, Till Kamppeter wrote:
> I have already written a patch for CUPS (currently used in the
> Ubuntu and Debian packages) which searches the whole PostScript
> header of incoming PostScript jobs (up to the place where the second
> page starts) for embedded option settings and adds the embedded
> settings to the IPP attributes/filter command line. I have done this
> for the PDF printing workflow. In the PDF printing workflow all
> incoming jobs get turned to PDF, then page management is done on PDF
> and PDF is fed into the driver. As this would loose option settings
> embedded in an incoming PostScript data stream I have made the patch.
>
> This patch does not slow down the printing workflow, as it also does
> not scan 1000s of pages in big documents. It could help you, as it
> makes sure that options in the PostScript data get into the command
> line. With it it is even not needed to add job ticket comments as
> "code" to the options in the PPD.
>
> The patch is attached.
>
> Till
>
> David Rosky wrote:
>> On Fri, Aug 28, 2009 at 11:03 AM, Alastair M. Robinson <blackfive@...
>> <mailto:blackfive@...>> wrote:
>> Hi
>> Michael Sweet wrote:
>> > No, it has to be in the initial comments section - cupsd
>> doesn't scan
>> > past that for performance reasons.
>> Hmmmm, pity - the simple fix eludes us once again!
>> Perhaps it would be possible to add a switch to cupsd that would
>> enable a more exhaustive search at the expense of performance for
>> these special cases.
>> Dave
>> ------------------------------------------------------------------------
>> ------------------------------------------------------------------------------
>> Let Crystal Reports handle the reporting - Free Crystal Reports
>> 2008 30-Day trial. Simplify your report design, integration and
>> deployment - and focus on what you do best, core application
>> coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july
>> ------------------------------------------------------------------------
>> _______________________________________________
>> Gimp-print-devel mailing list
>> Gimp-print-devel@...
>> https://lists.sourceforge.net/lists/listinfo/gimp-print-devel
>
> #! /bin/sh /usr/share/dpatch/dpatch-run
> ## read-embedded-options-from-incoming-postscript-and-add-to-ipp-
> attrs.dpatch by <till.kamppeter@...>
> ##
> ## All lines beginning with `## DP:' are a description of the patch.
> ## DP: No description.
>
> @DPATCH@
> diff -urNad cups~/scheduler/ipp.c cups/scheduler/ipp.c
> --- cups~/scheduler/ipp.c 2009-06-23 11:48:45.000000000 +0100
> +++ cups/scheduler/ipp.c 2009-06-23 14:48:06.000000000 +0100
> @@ -7790,6 +7790,11 @@
> ipp_attribute_t *attr, /* Current attribute */
> *attr2, /* Job attribute */
> *prev2; /* Previous job attribute */
> + int foundfirstpage; /* Did we find the first
> page already
> + in the PostScript input? */
> + int num_copies; /* Number of copies
> according to
> + PostScript command in input file */
> + char *s, *t, buffer[10];
>
>
> /*
> @@ -7853,6 +7858,85 @@
> }
>
> /*
> + * Read option settings embedded in the file...
> + */
> +
> + foundfirstpage = 0;
> +
> + while (cupsFileGets(fp, line, sizeof(line)))
> + {
> + /*
> + * Stop at the second page, we read also the settings of the
> first PageSetup
> + * to work around a bug in OpenOffice.org. This app puts options
> intended
> + * for the whole document into the page setup of the first page
> + */
> +
> + if (!strncmp(line, "%%Page:", 7))
> + {
> + if (foundfirstpage == 1)
> + break;
> + foundfirstpage = 1;
> + }
> +
> + /*
> + * Add the embedded option settings to the option array...
> + */
> +
> + s = NULL;
> + if (!strncmp(line, "%%BeginFeature:", 15))
> + s = line + 15;
> + else if (!strncmp(line, "%%IncludeFeature:", 17))
> + s = line + 17;
> + else if (!strncmp(line, "%%BeginNonPPDFeature:", 21))
> + s = line + 21;
> +
> + if (s && (t = strstr(s, "NumCopies")) != NULL)
> + {
> + t += 9;
> + while ((*t == ' ') || (*t == '\t')) t++;
> + if (sscanf(t, "%9d", &num_copies) == 1)
> + {
> + sprintf(buffer, "%d", num_copies);
> + num_options = cupsAddOption("copies", buffer, num_options,
> &options);
> + }
> + }
> + else if (s)
> + {
> + while ((*s == ' ') || (*s == '\t')) s++;
> + if (*s == '*') s++;
> + t = s;
> + while (*t && (*t != ' ') && (*t != '\t')) t++;
> + if ((*t == ' ') || (*t == '\t')) *t = '=';
> + num_options = cupsParseOptions(s, num_options, &options);
> + }
> +
> + /*
> + * Read out "/#copies XXX def" and "/NumCopies XXX def"
> expressions from
> + * PostScript input. Some apps insert these expressions to set the
> + * number of copies.
> + */
> +
> + s = NULL;
> + if ((s = strstr(line, "/#copies")) != NULL)
> + s += 8;
> + else if ((s = strstr(line, "/NumCopies")) != NULL)
> + s += 10;
> + if (s)
> + {
> + while ((*s == ' ') || (*s == '\t')) s++;
> + if (sscanf(s, "%9d %as ", &num_copies, &t) == 2)
> + {
> + if (!strncmp(t, "def", 3))
> + {
> + sprintf(buffer, "%d", num_copies);
> + num_options = cupsAddOption("copies", buffer, num_options,
> &options);
> + }
> + free(t);
> + }
> + }
> + }
> +
> + /*
> * Done with the file; see if we have any options...
> */
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
> 30-Day
> trial. Simplify your report design, integration and deployment - and
> focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now. http://p.sf.net/sfu/bobj-july_______________________________________________
> Gimp-print-devel mailing list
> Gimp-print-devel@...
> https://lists.sourceforge.net/lists/listinfo/gimp-print-devel
___________________________________________________
Michael Sweet, Senior Printing System Engineer
|