CUPS 1.2.7: definitions in .convs and .types not working

Michael Leimann mleimann at europe.com
Tue Jan 20 02:54:04 PST 2009


> > Hello to everyone!
> >
> > We are facing a problem with a CUPS filter script that we are unable to fix.
> >
> > Szenario:
> >
> > We have a CUPS-Server 1.2.7 (cups-1.2.7-12.7, cups-libs-1.2.7-12.7, cups-backends-1.0-43, cups-drivers-1.2.7-7, cups-client-1.2.7-12.7, libgnomecups-0.2.2-46)
> >
> > - openSUSE 10.2
> > - kernel 2.6.18.8-0.7
> >
> > installed and running fine.
> >
> > In /usr/lib/cups/filter we have defined a script that is meant to mix printing with our letterhead:
> >
> > -rwxr-xr-x 1 root    root   1440  9. Jan 11:00 withform
> >
> > #! /bin/bash
> > # see http://localhost:631/spm.html#WRITING_FILTERS
> > # debug info in /var/log/cups/error_log
> > set -x
> > # set inputfile to where the input comes from
> > inputfile="-"
> > [ -n "$6" ] && inputfile="$6"
> > # does /tmp/print exist?
> > outputfile=`ls -al /tmp | grep "^d"  | cut -d ":" -f 2 | cut -b 4- | grep "print"`
> > if [ "$outputfile" == "" ]; then
> >    mkdir /tmp/print
> > fi
> > # define outputfile
> > outputfile=`date "+%Y%m%d%H%M%S"`
> > # piping printjob in one file per page
> > gs -q -dBATCH -dNOPAUSE -sDEVICE=pswrite -sOutputFile=/tmp/print/$outputfile-%03d.ps $inputfile
> > #combining pages with overlay
> > for pagefile in /tmp/print/$outputfile-*
> > do
> >   page=`echo $pagefile | cut -d "-" -f 2 | cut -d "." -f 1`
> >   if [ "$pagefile" = "/tmp/print/$outputfile-001.ps" ]; then
> >      # 1. page
> >      overlay="/usr/lib/cups/filter/letterhead1.eps"
> >      else
> >         # all other pages
> >         overlay="/usr/lib/cups/filter/letterhead2.eps"
> >   fi
> >   # printing, EPS comes first, because it clears the page!
> >   gs -q -dBATCH -dNOPAUSE -sPAPERSIZE=a4 -sDEVICE=pswrite -sOutputFile=/tmp/print/tmp-$outputfile.ps $overlay $pagefile
> >   /usr/bin/pstops "2:0(0,0)+1(0,0)" /tmp/print/tmp-$outputfile.ps /tmp/print/final-$outputfile-$page.ps > /dev/null 2>&1
> >   rm $pagefile
> >   rm /tmp/print/tmp-$outputfile.ps
> > done
> > cat /tmp/print/final-$outputfile*ps
> > rm /tmp/print/final-$outputfile-*.ps
> > # for tracing purposes
> > echo "WITHFORM $(date)" | tee -a /var/log/cups/error_log
> >
> >
> > When using
> >
> > *cupsFilter: "application/vnd.cups-postscript 0 withform"
> >
> > in a printer specific PPD file, we get the output printed as intended.
> >
> > To be able to use this on all our printers, we don't want to use the way via the PPD file. We want do include something like
> >
> > #Form:...
> >
> > in the printout we intend to search for the "#Form:" statement. Later we want the filter script to select pre defined EPS forms from the "..." extension of the statement.
> >
> > Therefore in /etc/cups we have defined
> >
> > -rw-r--r-- 1 root root 184 14. Jan 09:39 form-ps.convs
> >
> > ########################################################################
> > #
> > # PostScript filters
> > #
> >
> > application/form-ps     application/postscript 33      /usr/lib/cups/filter/withform
> >
> >
> > and
> >
> > -rw-r--r-- 1 root root 178 14. Jan 09:41 form-ps.types
> >
> > ########################################################################
> > #
> > # Application-generated files...
> > #
> >
> > application/form-ps             contains(0,900000,"<23466F726D3A")
> >
> >
> > We have played around with different detection methods in form-ps.types and different application settings (e.g. application/vnd.cups-postscript) in form-ps.convs. We had included such lines in mime.convs and mime.types, even though this is not the suggested way. Of course we have restarted CUPS whenever we made changes. Under no circumstances our filter script was used by cups.
> >
> > Any suggestions. What are we doing wrong?
> >
> > Regards
> >
> > Michael
> >
>
> When amending form-ps.types to
>
> ########################################################################
> #
> # Application-generated files...
> #
>
> application/form-ps             contains(0,900000,"#Form:")
>
> and doing
>
> echo "#Form:TEST" >test
> lp -d <printer> test
>
> we get the following entry in /var/log/cups/error_log
>
> D [19/Jan/2009:11:54:40 +0100] print_job: auto-typing file...
> D [19/Jan/2009:11:54:40 +0100] print_job: request file type is application/form-ps.
> D [19/Jan/2009:11:54:40 +0100] Print-Job client-error-document-format-not-supported: Unsupported format 'application/form-ps'!
> D [19/Jan/2009:11:54:40 +0100] cupsdProcessIPPRequest: 10 status_code=40a (client-error-document-format-not-supported)
>
> So at least CUPS must
>
> a) use our form-ps.types and
> b) recognize the content of the file by the contains statement.
>
> Did we do a mistake in the form-ps.convs?
>
> Regards
>
> Michael
>

This is a very quite forum!

Hey, come on boys and girls, I need a bit of help here. Looks as if I am talking to myself ;-).

When amending form-ps.convs to

########################################################################
#
# PostScript filters
#
application/form-ps     application/postscript 33      withform

(full path to filter was found when researching the subject before) and doing

echo "#Form:TEST" >test
lp -d <printer> test

we get the following entry in /var/log/cups/error_log

D [20/Jan/2009:10:08:05 +0100] [Job 4765] envp[20]="CONTENT_TYPE=application/form-ps"
D [20/Jan/2009:10:08:05 +0100] [Job 4765] envp[21]="DEVICE_URI=lpd://192.168.3.99/print_600-605"
D [20/Jan/2009:10:08:05 +0100] [Job 4765] envp[22]="PRINTER=P051-99"
D [20/Jan/2009:10:08:05 +0100] [Job 4765]
envp[23]="FINAL_CONTENT_TYPE=application/vnd.cups-postscript"
I [20/Jan/2009:10:08:05 +0100] Started filter /usr/lib/cups/filter/withform
(PID 26723) for job 4765.

That's nice, because it showes that everything is working well, ...

except the contains(offset,range,"string") statement. We are aware of

#   String constants must be surrounded by "" if they contain whitespace.
#   To insert binary data into a string, use the <hex> notation.

Due to the fact that we are using standard applications (e.g. OpenOffice) to print, we are primarily generating Postscript.

Our "#Form:..." statement in the Postscript source looks like this:

[...]
%%EndPageSetup
gsave
[0.12 0 0 -0.12 14 828] concat
gsave
358 450 moveto
0 setgray
(ThorndaleAMTFID116HGSet1) cvn findfont 100 -100 matrix scale makefont setfont
<23466F726D3A544C424631> <- HERE IT IS!
[50 55 51 33 77 28 62 61 66 56 0]
xshow
[...]

#(=23)
F(=46)
o(=6F)
r(=72)
m(=6D)
:(=3A)

That is what we hoped to find with

contains(0,900000,"<23466F726D3A") or
contains(0,900000,"23466F726D3A") or
contains(0,900000,23466F726D3A) or
contains(0,900000,<23466F726D3A>) or
contains(0,900000,"#Form:")or
...

What are we doing wrong here? Isn't is possible to search within a Postscript source?

Waiting for you help!

Regards

Michael





More information about the cups mailing list