Printing to file with cups

I saw with RHEL8 their decision to drop cups using /etc/cups/interfaces files a short time ago which is a big slap for those who need to manipulate resulting application printer output into files or other interfaces for conversion, filing, emailing etc.
Is there a work around as you can’t use:

lpadmin -p printername -i /tmp/scripted_interface -v file://dev/null

or anything similar that I can find. I have to leave Rocky and go back to CentOS 7 to keep this capability which I really don’t want to do if there is something I missed or an additional package that allows this? No use producing a PDF (as in CUPS-PDF) as we need the actual application data produced first.

Went back to CentOS 7 for this issue. Will investigate work-around for this into the future now it has removed this vital feature from application printing by Red Hat.

The problem is upstream cups 2.2 disabled it.

Now RedHat document a work-around at Printing Interface Scripts No Longer Supported in RHEL 8 - Red Hat Customer Portal

it requires a subscription, but you can create a freebie developer subscription to access it.

Basically, to use their example, a “toupper” filter:

Create /usr/lib/cups/filters/toupper

#!/bin/bash
cat $6 | tr '[:lower:]' '[:upper:]'

Now create a ppd file:

*PPD-Adobe: "4.3"
*%
*% ToUpper PPD
*%
*FormatVersion: "4.3"
*FileVersion:   "1.1"
*LanguageVersion: English
*LanguageEncoding: ISOLatin1
*PCFileName:    "toupper.ppd"
*Manufacturer:  "My Company"
*Product:       "(ToUpper Interface Script)"
*cupsFilter:    "text/plain 0 toupper"
*cupsFilter:    "application/vnd.cups-raw 0 toupper"
*ModelName:     "ToUpper Interface Script"
*ShortNickName: "ToUpper Interface Script"
*NickName:      "ToUpper Interface Script"

Now define the printer:
lpadmin -p toupper -P ./toupper.ppd -v socket://some_printer/ -E

That should be enough to experiment with and create a similar function to the original.

OK…

% cat /usr/lib/cups/filter/tofile 
#!/bin/sh

cat "$6" > /tmp/afile

And then

% cat tofile.ppd 
*PPD-Adobe: "4.3"
*%
*% Blahblah
*%
*FormatVersion: "4.3"
*FileVersion:   "1.1"
*LanguageVersion: English
*LanguageEncoding: ISOLatin1
*PCFileName:    "tofile.ppd"
*Manufacturer:  "Me!"
*Product:       "(Blah)"
*cupsFilter:    "text/plain 0 tofile"
*ModelName:     "Blah"
*ShortNickName: "Blah"
*NickName:      "Blah"

So now:
lpadmin -p test -P ./tofile.ppd -v file:///dev/null

and finally:

% enable test
% accept test
% echo This is a test | lp -d test
request id is test-1 (0 file(s))
% cat /tmp/afile
This is a test

Wow, you are an absolute legend. Haven’t seen anything like this out there online and will give it a try and see how it all goes. Thank you so much. Will update you when I get it tested.

I have Fedora 33 as my desktop so has the same limitation - worked first time like a charm. This work-around is just what will keep SystemV type apps alive into the future.
Well done indeed.