CUPS 1.2.7: definitions in .convs and .types not working
Michael Leimann
mleimann at europe.com
Thu Jan 15 23:55:35 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
More information about the cups
mailing list