CUPS PS preprocessing filter

asbjoern luedtke asbjoern_luedtke at starkey.de
Thu Mar 6 14:59:49 PST 2008


Hi,

following resources on this forum I added a PS preprocessing filter with a search & replace functionality:

1. Add a new mime type application/postscript-prefiltered to /etc/cups/mime.types by appending the following line:

   application/postscript-prefiltered

2. Insert an additional line in /etc/cups/mime.convs. Modify the pstops line as follows:

   application/postscript application/postscript-prefiltered 10 PsPrefilter
   application/postscript-prefiltered application/vnd.cups-postscript 66 pstops

3. Create custom filter /usr/lib/cups/filter/PsPrefilter

 #! /bin/bash
 # see http://localhost:631/spm.html#WRITING_FILTERS
 # debug info in /var/log/cups/error_log
 set -x
 # have the input at fd0 (stdin) in any case
 [ -n "$6" ] && exec <"$6"
 # prefiltering
 sed 's|STRING_A|STRING_B|g'

4. Restart CUPS

4. print PS test file

5. verify that PSPrefilter has been applied - /var/log/cups/error_log

   I [06/Mar/2008:21:53:17 +0000] Adding start banner page "none" to job 27.
   I [06/Mar/2008:21:53:17 +0000] Adding end banner page "none" to job 27.
   I [06/Mar/2008:21:53:17 +0000] Job 27 queued on 'uk_is_gen2_bm' by 'root'.
   I [06/Mar/2008:21:53:17 +0000] Started filter /usr/lib/cups/filter/PsPrefilter (PID 23063) for job 27.
   I [06/Mar/2008:21:53:17 +0000] Started filter /usr/lib/cups/filter/pstops (PID 23064) for job 27.
   I [06/Mar/2008:21:53:17 +0000] Started filter /usr/lib/cups/filter/foomatic-rip (PID 23065) for job 27.
   I [06/Mar/2008:21:53:17 +0000] Started backend /usr/lib/cups/backend/lpd (PID 23066) for job 27.

However STRING_A is not replaced. Any input is appreciated.

Thanks already,
Asbjorn







More information about the cups mailing list