[cups] setting margins when printing a ps (postscript) file
Istvan Gabor
suseuser04 at freemail.hu
Fri Feb 20 13:20:51 PST 2015
Willy Offermans írta:
>Hello Gabor and CUPS friends,
>
>Could you also post the modifications you have made to mime.types and
>mime.convs in order to use the script? I would like to make a filter script
>myself and I need some info on how to.
Yes. I only followed the instructions in "Adding Additional Filter Stages to the Default CUPS Filter System" at https://en.opensuse.org/SDB:Using_Your_Own_Filters_to_Print_with_CUPS#Adding_Additional_Filter_Stages_to_the_Default_CUPS_Filter_System.
I edited /usr/share/cups/mime/mime.types: added the following line to the end of the file:
application/postscript-prefiltered
Note that the comment in the file suggests that you should create a file called "local.types" and add the above line to this file. It works as well.
Next I edited /usr/share/cups/mime/mime.convs file:
Original content:
-----
application/pdf application/vnd.cups-postscript 66 pdftops
application/postscript application/vnd.cups-postscript 66 pstops
application/x-cshell application/postscript 33 texttops
-----
Modified content:
----
application/pdf application/vnd.cups-postscript 66 pdftops
#application/postscript application/vnd.cups-postscript 66 pstops
application/postscript application/postscript-prefiltered 10 PsPrefilter
application/postscript-prefiltered application/vnd.cups-postscript 66 pstops
application/x-cshell application/postscript 33 texttops
----
You can also add the new line(s) to local.convs file instead of adding them to mime.convs, but you still have to comment/remove the corresponding line in mime.convs if you modify an existing conversion rule. For example I changed the application/postscript rule, therefore I commented (=removed) the original line that defined it.
After this I made the new filter file in /usr/lib/cups/filter named PsPrefilter and added what I posted before:
-----
#! /bin/bash
# have the input at fd0 (stdin) in any case:
# this makes sure that the input of the filter's command comes from standard input:
[ -n "$6" ] && exec <"$6"
# the actual filter command:
ps2pdf - -
-----
Make sure that the filter command takes standard input as input and outputs the data to standard output. How to achieve this depends on the given command. In my case these are the two dashes. Don't forget to make the file executable.
After editing the files you have to restart cups daemon:
/etc/init.d/cups restart (or the corresponding systemd command which I don't know).
Done.
UPDATE:
I also learned that there is a cupsPreFilter key that you can add to the printer queue's ppd file. Staying with the above filter example you add the following line to the ppd file (among the other keys):
*cupsPreFilter: "application/postscript 100 PsPrefilter"
Done. In this case you don't have to edit mime.types and mime.convs, only have to make the filter file.
What cupsPreFilter does is:
This string keyword provides a pre-filter rule. The pre-filter program will be inserted in the conversion chain immediately before the filter that accepts the given MIME type.
See: http://cups.org/documentation.php/doc-1.5/spec-ppd.html#cupsPreFilter
Regards,
Istvan
More information about the cups
mailing list