Menu

#57 media tray perl cmd in pxlmono.xml corrupts data

Runtime_problems
open
nobody
None
5
2012-09-14
2005-03-07
No

There's a perl command in pxlmono.xml which attempts to
substitute the media tray specified by the user into
the PCLXL file produced by ghostscript.

The problem is that the sequence of bytes for which
that perl command looks doesn't only happen when the
tray is being set; I've found that it can also happen
elsewhere, e.g., in raster graphics data.

I can provide a PostScript file which prints to my
PCLXL printer (Dell 3000cn) just fine when I run gs by
hand and feed the output to the parallel device, but
fails to print (the printer first asks me to insert A4
paper, and then when I claim I've done so reports a PCL
error) when I print it through foomatic. I've
confirmed that the only difference in the data sent to
the printer in the two cases is a byte changed by that
perl command where nothing should have been chainged,
i.e., it wasn't really a tray-setting command that the
perl command changed.

The right way to fix this is clearly to add support to
ghostscript for specifying the media tray in a
command-line option, so that the perl hack is no longer
necessary. Absent that, another fix I've thought of is
to modify the perl command to remove the "g", i.e., it
should only substitute the first instance of the
character pattern it's looking for. The two problems I
see with that are (a) I don't know for certain that the
tray-setting command always appears in the output, so
this might in some cases end up corrupting the data as
well, and (b) I don't know if it's legal for a
PostScript file, and hence a PCLXL file, to change
media trays in the middle, in which case it would in
fact be necessary to substitute the command multiple
times (but it seems to me that foomatic doesn't support
this either, because of course the pclmono XML doesn't
allow you to specify multiple trays for a single job!).

For my own personal use, I've removed the "g" from the
perl command, since I don't really have time to figure
out how to fix ghostscript properly and then modify
foomatic to use the ghostscript fix.

Discussion

  • Jonathan Kamens

    Jonathan Kamens - 2005-05-29

    Logged In: YES
    user_id=274776

    My fix is wrong, since it will substitute the first apparent
    paper-tray command on any line in the file, as opposed to
    only substituting the first command in the entire file.

     
  • Nobody/Anonymous

    Logged In: NO

    The fix I proposed above isn't sufficient. Removing the "g"
    prevents it from doing the substitution multiple times on
    the same line of data ("line" as far as Perl is concerned),
    but not if the pattern appears on different lines of data in
    the PCLXL output. I changed the command in pxlmono.xml to
    look like this:

    <prototype>gs -q -dBATCH -dPARANOIDSAFER -dNOPAUSE%B%A%Z
    -sOutputFile=- - | perl -p -e 'if (! $did) {
    s/\xc0.\xf8\x26/\xc0%E\xf8\x26/ && $did++;
    }'</prototype>

     

Log in to post a comment.

MongoDB Logo MongoDB