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

pstops filter corrupts PostScript #1470

michaelrsweet opened this issue Mar 9, 2006 · 4 comments

pstops filter corrupts PostScript #1470

michaelrsweet opened this issue Mar 9, 2006 · 4 comments


Copy link

@michaelrsweet michaelrsweet commented Mar 9, 2006

Version: 1.2-current User: till.kamppeter

I am on CUPS 1.2 beta 1 now (SVN rev 5256) but it happened already on rev 5239.

It seems there is a bug in the pstops filter which breaks the PostScript.

To reproduce:

Get HP's PPD file for the HP LaserJet 4050

to have a pure PostScript printer which does not need GhostScript.

Add "FileDevice Yes" to /etc/cups/cupsd.conf and restart CUPS.

Set up a print queue with the downloaded PPD file:

lpadmin -p LJ4050 -E -v file:/tmp/printout -P HP_LaserJet_4050_Series.ppd.gz -o PageSize=A4

Print a job:

lpr /usr/share/cups/data/

Try to display the /tmp/printout which should be PostScript:

gs -sDEVICE=x11 /tmp/printout

You will get output as follows:

[root@majax c]# gs -sDEVICE=x11 /tmp/printout
ESP Ghostscript 815.01 (2005-09-22)
Copyright (C) 2004 artofcode LLC, Benicia, CA. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Loading NimbusSanL-Bold font from /usr/share/fonts/default/Type1/n019004l.pfb... 2591852 1022928 1677540 358286 1 done.
Using NimbusSansL-Bold font for NimbusSanL-Bold.

Error: /undefined in stoppe

Additional information: [/Duplex false]
Operand stack:
--nostringval-- --nostringval--
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1 3 %oparray_pop 1 3 %oparray_pop 1 3 %oparray_pop 1 3 %oparray_pop .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval--
Dictionary stack:
--dict:1115/1686(ro)(G)-- --dict:0/20(G)-- --dict:95/200(L)--
Current allocation mode is local
Last OS error: 2
Current file position is 9588
ESP Ghostscript 815.01: Unrecoverable error, exit code 1

[root@majax c]#

There is an "Error: /undefined in stoppe"

This indicates that the PostScript is broken (My LaserJet 4050 here prints a similar error message when I print this file with "nc -w1 9100 < /tmp/printout").

If I edit the file and fix the problem, The file can be correctly displayed and printed. To try it out, find

} stoppe% x y w h ESPrc - Clip to a rectangle.

and fix is as follows

} stopped cleartomark

% x y w h ESPrc - Clip to a rectangle.

Alternatively, you can get CUPS producing a correct file directly. Edit /etc/cups/mime.convs to deactivate pstops:


application/postscript application/vnd.cups-postscript 66 pstops


application/postscript application/vnd.cups-postscript 66 -

Then /tmp/printout can directly be displayed or printed, but without pstops most option settings are ignored.

So the problem clearly lies in the pstops filter.

Copy link
Contributor Author

@michaelrsweet michaelrsweet commented Mar 9, 2006 User: till.kamppeter

Additional note:

I did not observe the problem in rev 5205, so the regression seems to be between rev 5205 and rev 5239.

Copy link
Contributor Author

@michaelrsweet michaelrsweet commented Mar 9, 2006 User: mike

According to the subversion history, there are no changes to pstops.c between r5205 and HEAD.

What did change is the underlying implementation of ppdEmit*() - looking into it now...

Copy link
Contributor Author

@michaelrsweet michaelrsweet commented Mar 9, 2006 User: mike

Fixed in Subversion repository.

The problem was simply that ppdEmitString() wasn't adding room for the newline we add to commands that are missing a trailing newline - the attached patch fixes things up - we'll be rolling a second beta at the end of the week to address this and any other issues that come up...

Copy link
Contributor Author

@michaelrsweet michaelrsweet commented Mar 9, 2006


Index: emit.c

--- emit.c (revision 5256)
+++ emit.c (working copy)
@@ -527,7 +527,7 @@
!strcasecmp(choices[i]->option->keyword, "PageRegion")) &&
!strcasecmp(choices[i]->choice, "Custom"))

  •    bufsize += 37;         /\* %%BeginFeature: *CustomPageSize True */
  •    bufsize += 37;         /\* %%BeginFeature: _CustomPageSize True\n */
     bufsize += 50;         /_ Five 9-digit numbers + newline */

    else if (!strcasecmp(choices[i]->choice, "Custom") &&
    @@ -535,8 +535,8 @@
    != NULL)

  •    bufsize += 23 + strlen(choices[i]->option->keyword);
  •               /\* %%BeginFeature: *keyword True */
  •    bufsize += 17 + strlen(choices[i]->option->keyword) + 6;
  •               /* %%BeginFeature: *keyword True\n */
     for (cparam = (ppd_cparam_t *)cupsArrayFirst(coption->params);

    @@ -562,16 +562,16 @@

  •    bufsize += 19 + strlen(choices[i]->option->keyword) +
  •          strlen(choices[i]->choice);
  •               /\* %%BeginFeature: *keyword choice */
  •    bufsize += 17 + strlen(choices[i]->option->keyword) + 1 +
  •          strlen(choices[i]->choice) + 1;
  •               /* %%BeginFeature: *keyword choice\n */

    bufsize += 13; /* %%EndFeature\n /
    bufsize += 22; /
    } stopped cleartomark\n */

    if (choices[i]->code)

  •  bufsize += strlen(choices[i]->code);
  •  bufsize += strlen(choices[i]->code) + 1;

    bufsize += strlen(ppd_custom_code);

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

Successfully merging a pull request may close this issue.

None yet
1 participant