CUPS 1.2.7: definitions in .convs and.types notworking (SOLVED)
Michael Leimann
mleimann at europe.com
Fri Jan 23 02:24:01 PST 2009
> Michael Leimann wrote:
> >> (Please remember that this isn't a commercial support forum, and
> >> any responses you get are from users and developers in their free
> >> time. Not seeing a response over a weekend is not unusual...)
> >>
> >> Michael Leimann wrote:
> >>> ...
> >>> 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?
> >> contains() currently only allows ranges of up to 4096 bytes. This
> >> currently isn't documented anywhere but the source, but is a trade-
> >> off we made years ago for efficiency's sake (otherwise in your rule
> >> we'd have to read the first 900000 bytes of every print file, which
> >> will have serious a performance impact...)
> >>
> >> --
> >> ______________________________________________________________________
> >> Michael R Sweet Senior Printing System Engineer
> >>
> >
> > Thank you very much for this valuable information! I did not want to urge you to answer me, I only tried to promote my problem ;-).
> >
> > I agree, you are quite right regarding the performance impact. I did not want to do this (not knowing about the 4k limitation), but to make 100% sure that the "range" value is not my problem. I have created a one letter document (+"#Form:...") with OpenOffice Writer and printed it into a file:
> >
> > ll -h test.ps
> > -rw-r--r-- 1 mleimann dummy 37K 20. Jan 10:26 test.ps
> >
> > grep -b "<23466F726D3A544C424631>" test.ps
> > 36909:<23466F726D3A544C424631>
> >
> > This shows that I with ordinary methods a user is not able to set a searchable tag in a Postscript file.
> >
> > Any suggestion to help me out of this misery?
>
> If you are always printing from a particular application, you can
> probably look for that application in the PostScript header, and
> then have your filter always get used. The filter can then do any
> substitutions it finds.
>
> --
> ______________________________________________________________________
> Michael R Sweet Senior Printing System Engineer
>
Thanks!
That's what I already planed to do. It is not nice but works. Maybe sooner or later an idea comes across how to steer that via an insertion into the DSC comments.
I do not know whether or not someone is interested in my weired ideas. For those of you who are, I post them hereafter:
-rw-r--r-- 1 root root /etc/cups/form-ps.types
THIS ONE HAS TO BE AVAILABLE ON ALL CLIENTS AS WELL!
########################################################################
#
# Application-generated files...
#
application/form-ps (string(0,%!) + \
contains(0,200,"Creator: (OpenOffice.org"))
-rw-r--r-- 1 root root /etc/cups/form-ps.convs
########################################################################
#
# PostScript filters
#
application/form-ps application/postscript 33 withform
-rwxr-xr-x 1 root root /usr/lib/cups/filters/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"`
# pipe input to file to make it searchable
cat $inputfile >/tmp/print/$outputfile-input.ps
# now set new inputfile
inputfile="/tmp/print/$outputfile-input.ps"
# '#Form:' tag given?
form=`grep -m 1 "<23466F726D3A" $inputfile`
if [ "$form" != "" ]; then
# we have to do some work!
#
# piping printjob in one file per page
p=1
match="Yes"
while [ $match = "Yes" ]
do
page=$(echo $((p+1000)) | cut -b 2-4)
match=`psselect -p$p $inputfile /tmp/print/$outputfile-$page.ps 2>&1 | cut -d "[" -f 2 | cut -d "]" -f 1`
if [ $match == $p ]; then
p=$((p+1))
match="Yes"
else
match="No"
rm /tmp/print/$outputfile-$page.ps
fi
done
#gs -q -dBATCH -dNOPAUSE -sDEVICE=pswrite -sOutputFile=/tmp/print/$outputfile-%03d.ps $inputfile
# removing inputfile
rm $inputfile
inputfile=""
#combining pages with overlay
for inputfile in /tmp/print/$outputfile-*
do
page=`echo $inputfile | cut -d "-" -f 2 | cut -d "." -f 1`
form=`grep -m 1 "<23466F726D3A" $inputfile`
case $form in
\<23466F726D3A544C424631\>)
overlay="/usr/lib/cups/filter/TOP-LAMP-Briefbogen1.eps";
sed -e 's/<23466F726D3A544C424631>/< >/g' $inputfile >/tmp/print/$outputfile-tmp.ps;
rm $inputfile;
mv /tmp/print/$outputfile-tmp.ps $inputfile;;
\<23466F726D3A544C424632\>)
overlay="/usr/lib/cups/filter/TOP-LAMP-Briefbogen2.eps";
sed -e 's/<23466F726D3A544C424632>/< >/g' $inputfile >/tmp/print/$outputfile-tmp.ps;
rm $inputfile;
mv /tmp/print/$outputfile-tmp.ps $inputfile;;
*)
overlay="";;
esac
# printing, EPS comes first, because it clears the page!
# can -PAPERSIZE=a4 deleted to make it work on all sorts of paper?
gs -q -dBATCH -dNOPAUSE -sPAPERSIZE=a4 -sDEVICE=pswrite -sOutputFile=/tmp/print/tmp-$outputfile-$page.ps $overlay $inputfile
rm $inputfile
# this is the trick!
# offset of -0.035cm is only for specific printer!
/usr/bin/pstops "2:0(0,-0.035cm)+1(0,0)" /tmp/print/tmp-$outputfile-$page.ps /tmp/print/final-$outputfile-$page.ps > /dev/null 2>&1
rm /tmp/print/tmp-$outputfile-$page.ps
done
inputfile=""
# this is a litte funny but seems to be necessary (merge all into one file for later cat to stdout)
gs -q -dBATCH -dNOPAUSE -sDEVICE=pswrite -sOutputFile=/tmp/print/print-$outputfile.ps /tmp/print/final-$outputfile-*.ps
rm /tmp/print/final-$outputfile-*.ps
else
# nothing left to do!
mv $inputfile /tmp/print/print-$outputfile.ps
inputfile=""
fi
cat /tmp/print/print-$outputfile.ps
rm /tmp/print/print-$outputfile.ps
There is only one question remaining:
Why do we have to have form-ps.types on all clients joining our network where we have two (to make it failover) CUPS-Servers?
Kind regards
Michael
More information about the cups
mailing list