[cups.general] (long) Filter script on raw printer?

Tony Wood tonyw at reynolds.com.au
Mon Nov 22 16:38:46 PST 2004


I am new to CUPS too.

My suggestion is don't do it!!!

We have many people who insist that the only thing printed to printer "X" is 
ascii text. These people know that we send PCL to that same printer but 
because they looked at the PCL they have determined that to be ascii text. 
PCL is a binary format so those documents that include graphics are 
constantly corrupted. What you are trying to do then is something similar 
where ALL output to the printer has any occurrance of LF is converted to 
CR/LF which is in some situation is incorrect and will corrupt the data 
being sent.  Be aware of this warning.

One option;
The CUPS documentation talks about how to write a filter. Read that 
documentation as it contains everything you need to know. I wrote a filter 
in perl based on this documentation.

The next step is getting the filter into the data stream to do what you want 
(heeding the warning above). For that you will need to create PPD file for 
the printer and include a line in the PPD like

*cupsFilter:    "text/plain 0 NameOfFilter"

Another option;

Create a shell script to submit the job to lp for you and use that rather 
than lp - call it lpcrlf;

cat - | awk '{printf "%s\r\n", $0}' | lp $@

This works with bash but should with any shell you use.

This is quicker and then means the printer can still be used to print binary 
files too. The script passes all of the options given to it to the lp 
command.

Which ever method you choose or pick pieces from it can be made to work 
because we do something similar here.

Regards,

T. 






More information about the cups mailing list