[cups] custom own filter for specifuc queue only

Johannes Meixner jsmeix at suse.de
Mon Feb 23 03:28:23 PST 2015


Hello,

On Feb 19 16:32 Istvan Gabor wrote (excerpt):
> There is a cupsPreFilter option mentioned in the referred docoument:
> http://cups.org/documentation.php/doc-1.5/spec-ppd.html#cupsPreFilter
...
> Have you only missed this one or it cannot be used?

Scary! I missed it - seems professional blinkers.

According to
http://cups.org/documentation.php/doc-1.5/spec-ppd.html#cupsPreFilter
a cupsPreFilter cannot be used to change the MIME type.
Input MIME type and output MIME type must be same
for a cupsPreFilter which means /usr/bin/ps2ps can be
used for a cupsPreFilter but /usr/bin/ps2pdf cannot.

I tested both on openSUSE 13.2 with CUPS 1.5.4:

In my Postscript.ppd (see my previous mail)
I have now the only cups*Filter entry:
---------------------------------------------------------------------
*% Prefilter for PostScript input
*cupsPreFilter: "application/postscript 0 PsPrefilter"
---------------------------------------------------------------------

First I used the /usr/lib/cups/filter/PsPrefilter 
---------------------------------------------------------------------
#! /bin/bash
set -x
# have the input at fd0 (stdin) in any case
[ -n "$6" ] && exec <"$6"
/usr/bin/ps2ps -sPAPERSIZE=a4 - - | /usr/bin/tee /tmp/ps2ps.out
---------------------------------------------------------------------
I have "set -x" and "| /usr/bin/tee /tmp/ps2ps.out"
only for my testing and debugging.

Printing test (cf. my previous mail):
---------------------------------------------------------------------
# echo Hello | lp -d testy
request id is testy-45 (0 file(s))
---------------------------------------------------------------------
results
---------------------------------------------------------------------
# grep PID /var/log/cups/error_log
I [23/Feb/2015:12:14:05 +0100] [Job 45]
  Started filter /usr/lib/cups/filter/texttops (PID 5983)
I [23/Feb/2015:12:14:05 +0100] [Job 45]
  Started filter /usr/lib/cups/filter/PsPrefilter (PID 5984)
I [23/Feb/2015:12:14:05 +0100] [Job 45]
  Started filter /usr/lib/cups/filter/pstops (PID 5985)
D [23/Feb/2015:12:14:05 +0100]
  PID 5983 (/usr/lib/cups/filter/texttops) exited with no errors.
D [23/Feb/2015:12:14:05 +0100]
  PID 5985 (/usr/lib/cups/filter/pstops) exited with no errors.
D [23/Feb/2015:12:14:05 +0100]
  PID 5984 (/usr/lib/cups/filter/PsPrefilter) exited with no errors.

# file /tmp/testy.out /tmp/ps2ps.out
/tmp/testy.out: PostScript document text ...
/tmp/ps2ps.out: PostScript document text ...
---------------------------------------------------------------------

Then I used that /usr/lib/cups/filter/PsPrefilter
---------------------------------------------------------------------
#! /bin/bash
set -x
# have the input at fd0 (stdin) in any case
[ -n "$6" ] && exec <"$6"
/usr/bin/ps2pdf -sPAPERSIZE=a4 - - | /usr/bin/tee /tmp/ps2pdf.out
---------------------------------------------------------------------

Printing test
---------------------------------------------------------------------
# echo Hello | lp -d testy
request id is testy-46 (0 file(s))
---------------------------------------------------------------------
results
---------------------------------------------------------------------
# grep PID /var/log/cups/error_log
I [23/Feb/2015:12:16:08 +0100] [Job 46]
  Started filter /usr/lib/cups/filter/texttops (PID 6018)
I [23/Feb/2015:12:16:08 +0100] [Job 46]
  Started filter /usr/lib/cups/filter/PsPrefilter (PID 6019)
I [23/Feb/2015:12:16:08 +0100] [Job 46]
  Started filter /usr/lib/cups/filter/pstops (PID 6020)
D [23/Feb/2015:12:16:09 +0100]
  PID 6018 (/usr/lib/cups/filter/texttops) exited with no errors.
D [23/Feb/2015:12:16:09 +0100]
  PID 6019 (/usr/lib/cups/filter/PsPrefilter) exited with no errors.
D [23/Feb/2015:12:16:09 +0100]
  PID 6020 (/usr/lib/cups/filter/pstops) exited with no errors.

# file /tmp/testy.out /tmp/ps2pdf.out
/tmp/testy.out:  PostScript document text ...
/tmp/ps2pdf.out: PDF document, version 1.4
---------------------------------------------------------------------

I did not expect that "pstops exited with no errors" even
when it gets PDF as input. In this case it only complains a bit
in /var/log/cups/error_log that
---------------------------------------------------------------------
This document does not conform to the Adobe Document Structuring
Conventions and may not print correctly.
---------------------------------------------------------------------

I.e. (mis)using cupsPreFilter for a conversion from PostScript
into PDF may result that it does not print correctly.

Indeed the /tmp/testy.out is now (with ps2pdf) broken:
---------------------------------------------------------------------
# gs -r50 -dNOPAUSE -dBATCH -sDEVICE=nullpage /tmp/testy.out
GPL Ghostscript 9.15 (2014-09-22)
...
Error: /undefined in obj
...
GPL Ghostscript 9.15: Unrecoverable error, exit code 1
---------------------------------------------------------------------

In contrast the /tmp/testy.out from before (with ps2ps)
does not show any error in Ghostscript.


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