Using a Perl script backend to handle a printfile

David Coventry dgcoventry at gmail.com
Tue Mar 10 12:56:25 PDT 2009


Michael,

Thanks for the reply.

> David Coventry wrote:
> > I have placed a simple Perl script in /usr/lib/cups/backed
>
> Your Perl script is reading from stdin, but based on the command you
> used to create the queue it will always get the print file on the
> command-line...

Ok. There appears to be nothing coming in from the stdin, but it wouldn't seem to be a problem because I can presumably recover the printer input from the d00014-001 file name? In fact on the system I'm using to test my script, the actual print files are named as c00014, although the system which will actually host the script, the file names correlate in the /var/spool/cups/ and with the name passed to the script on the command line.

> > ...
> > However, the print file is generated in /va/spool/cups and not in
> > /var/spool/cups/pdf as I would expect. Also the filename as passed to
> > /tmp/test.prn is of the order /var/spool/cups/d00014-001 as opposed
> > to the actual file generated, which is /var/spool/cups/c00014.
>
> The "c" files are the job control files which contain the current IPP
> attributes for each job.  The "d" files are the job document files
> which will be in whatever format the user submits - if you get the
> print file on the command-line (which is what happens for raw queues),
> look at the CONTENT_TYPE environment variable for the file type.
> > Furthermore the file does not contain raw text as expected.
>
> Are you printing raw text files?

At the moment the prints sent to the printers currently set up produce their output in raw format.

> > Can anyone suggest how I can:
> >
> > a) make sure that the script is passed the correct file name and b)
> > ensure that the file generated is plain text.
>
> a) it *is* being passed the correct filename, and b) you can't unless
> you provide filters and a PPD file that tells CUPS about those
> filters.

I'm not sure why I can't find the file d00014-001 on my test system, then. No matter; as long as the name is correct on the real system, then I'm not too worried.

> If you only want to accept plain text files, then a PPD file
> containing a cupsFilter line for text/plain should do the trick:
>
>      *PPD-Adobe: "4.3"
>      *NickName: "My PDF text printer"
>      *cupsFilter: "text/plain 0 -"

I have rendered a simulation of the printed sheets which would normally be pre-printed onto the printer paper in postscript and I plan to use this as a background for my PDF and to place the raw printer output onto that so that it replicates the dot matrix printing onto a pre-printed page.

In order to place the raw output into it's correct columns, I need the Perl script to count tabs and adjust the PS moveto to match. If the raw text is already formatted in Postscript it's obviously a lot more difficult.

Regards,

Dave Coventry




More information about the cups mailing list