summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTill Kamppeter <till.kamppeter@gmail.com>2016-08-09 18:11:27 +0200
committerDidier Raboud <odyx@debian.org>2018-06-11 19:26:52 +0200
commit5ec26c435b0b91e926c932a3deeb257c2aa3be9a (patch)
treeeeab4b1b552ce1936a2a4167149800e639d82e24
parentc08f77e7b10b20b165b016630673fcc995c3af43 (diff)
Make CUPS reading all option settings in PostScript print
jobs and add the option settings to the filter command line before starting the filter chain. This fixes the problem that in the PDF printing workflow (where incoming PostScript gets converted to PDF by pstopdf) option settings embedded in the incoming PostScript code do not get obeyed. Especially the options of jobs from Windows clients get ignored. Origin: vendor Bug: https://www.cups.org/str.php?L4344 Last-Update: 2015-02-10 Patch-Name: read-embedded-options-from-incoming-postscript-and-add-to-ipp-attrs.patch
-rw-r--r--scheduler/ipp.c84
1 files changed, 84 insertions, 0 deletions
diff --git a/scheduler/ipp.c b/scheduler/ipp.c
index d1c6a89fb..d1b9140d3 100644
--- a/scheduler/ipp.c
+++ b/scheduler/ipp.c
@@ -8721,6 +8721,11 @@ read_job_ticket(cupsd_client_t *con) /* I - Client connection */
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];
/*
@@ -8782,6 +8787,85 @@ read_job_ticket(cupsd_client_t *con) /* I - Client connection */
}
/*
+ * 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...
*/