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

Ignores option settings embedded in the incoming PostScript code #4344

Closed
michaelrsweet opened this issue Jan 16, 2014 · 2 comments
Closed

Ignores option settings embedded in the incoming PostScript code #4344

michaelrsweet opened this issue Jan 16, 2014 · 2 comments

Comments

@michaelrsweet
Copy link
Collaborator

@michaelrsweet michaelrsweet commented Jan 16, 2014

Version: 1.7.1
CUPS.org User: odyx

Hi Michael,

Till has included the attached patch in Debian's cups package with the following description:

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.

@michaelrsweet
Copy link
Collaborator Author

@michaelrsweet michaelrsweet commented Jan 16, 2014

CUPS.org User: mike

This will cause a lot of interoperability problems, particularly for PostScript that has been generated by a client system (a very common, if not particularly recommended, configuration).

Loading

@michaelrsweet
Copy link
Collaborator Author

@michaelrsweet michaelrsweet commented Jan 16, 2014

"read-embedded-options-from-incoming-postscript-and-add-to-ipp-attrs.patch":

Description: 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.
Author: Till Kamppeter till.kamppeter@gmail.com

--- a/scheduler/ipp.c
+++ b/scheduler/ipp.c
@@ -8273,6 +8273,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];

/*
@@ -8334,6 +8339,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...
      */

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant