[cups] custom own filter for specifuc queue only

Johannes Meixner jsmeix at suse.de
Thu Feb 19 05:34:32 PST 2015


Hello,

On Feb 19 13:20 Johannes Meixner wrote (excerpt):
> Perhaps one can create print queue specific filtering rules
> via the cupsFilter2 keyword in the PPD file, see
> http://cups.org/documentation.php/doc-1.5/spec-ppd.html

It works only to a certain extent.

Basically it seems you cannot do pre-filtering via cupsFilter2
but only define the last filtering step that results the
printer's native data format as described in
http://cups.org/documentation.php/doc-1.5/spec-ppd.html#cupsFilter2

What I did on openSUSE 13.2 with CUPS 1.5.4:

In /etc/cups/cupsd.conf I added "FileDevice yes"
and set "LogLevel debug" that I need only for my testing.

I get /usr/share/cups/model/Postscript.ppd.gz to modify it

# cp /usr/share/cups/model/Postscript.ppd.gz .

# gunzip Postscript.ppd.gz

# vi Postscript.ppd

as follows:
-------------------------------------------------------------------
--- Postscript.ppd.orig 2015-02-19 13:47:00.682389542 +0100
+++ Postscript.ppd      2015-02-19 13:44:47.478301491 +0100
@@ -26,6 +26,12 @@
  *LandscapeOrientation: Plus90
  *VariablePaperSize: False
  *TTRasterizer: Type42
+*% Filter for PostScript input
+*cupsFilter2: "application/postscript  application/foo 0 PsFilter"

  *UIConstraints: *PageSize Executive *InputSlot Manual
  *UIConstraints: *PageSize Letter *InputSlot Manual
-------------------------------------------------------------------

I made /usr/lib/cups/filter/PsFilter as follows:
-------------------------------------------------------------------
#! /bin/bash
# have the input at fd0 (stdin) in any case
[ -n "$6" ] && exec <"$6"
/usr/bin/ps2ps -sPAPERSIZE=a4 - -
-------------------------------------------------------------------

I restarted the cupsd so that it recognizes my new PsFilter.

I set up a test print queue for an imaginary PostScript printer
that outputs to a file and that uses my modified PPD file:

# lpadmin -p testy -v file:/tmp/testy.out -P Postscript.ppd -E

I do two test prints:

First test print is ASCII text:

# echo Hello | lp -d testy
request id is testy-36 (0 file(s))

# grep PID /var/log/cups/error_log
...
I [19/Feb/2015:14:24:13 +0100] [Job 36]
  Started filter /usr/lib/cups/filter/texttops (PID 31814)
I [19/Feb/2015:14:24:13 +0100] [Job 36]
  Started filter /usr/lib/cups/filter/PsFilter (PID 31815)
D [19/Feb/2015:14:24:13 +0100]
  PID 31814 (/usr/lib/cups/filter/texttops) exited with no errors.
D [19/Feb/2015:14:24:13 +0100]
  PID 31815 (/usr/lib/cups/filter/PsFilter) exited with no errors.

Second test print is PostScript:

# lp -d testy /usr/share/ghostscript/9.15/examples/colorcir.ps
request id is testy-37 (1 file(s))

# grep PID /var/log/cups/error_log
...
I [19/Feb/2015:14:28:09 +0100] [Job 37]
  Started filter /usr/lib/cups/filter/PsFilter (PID 31823)
D [19/Feb/2015:14:28:10 +0100]
  PID 31823 (/usr/lib/cups/filter/PsFilter) exited with no errors.

Note that in both cases there is no longer the CUPS standard
filter pstops executed. This filter does in particular insert
printer specific settings from the PPD into the data stream
which means without the pstops filter usually no printer
specific settings will work.

One can view each PostScript output in /tmp/testy.out with Ghostscript,
cf. https://en.opensuse.org/SDB:How_to_Report_a_Printing_Issue

# gs -r50 /tmp/testy.out

It looks correct.

To verify that other print queues are not affected:

# lpadmin -p testy2 -v file:/tmp/testy2.out \
  -P /usr/share/cups/model/Postscript.ppd.gz -E

# echo Hello | lp -d testy2
request id is testy2-38 (0 file(s))

# grep PID /var/log/cups/error_log
...
I [19/Feb/2015:14:29:23 +0100] [Job 38]
  Started filter /usr/lib/cups/filter/texttops (PID 31831)
I [19/Feb/2015:14:29:23 +0100] [Job 38]
  Started filter /usr/lib/cups/filter/pstops (PID 31832)
D [19/Feb/2015:14:29:23 +0100]
  PID 31832 (/usr/lib/cups/filter/pstops) exited with no errors.
D [19/Feb/2015:14:29:23 +0100]
  PID 31831 (/usr/lib/cups/filter/texttops) exited with no errors.

# lp -d testy2 /usr/share/ghostscript/9.15/examples/colorcir.ps
request id is testy2-39 (1 file(s))

# grep PID /var/log/cups/error_log
...
I [19/Feb/2015:14:30:23 +0100] [Job 39]
  Started filter /usr/lib/cups/filter/pstops (PID 31857)
D [19/Feb/2015:14:30:23 +0100] PID 31857
  (/usr/lib/cups/filter/pstops) exited with no errors.


Kind Regards
Johannes Meixner
-- 
SUSE LINUX GmbH - GF: Felix Imendoerffer, Jane Smithard, Jennifer Guild,
Dilip Upmanyu, Graham Norton - HRB 21284 (AG Nuernberg)




More information about the cups mailing list