- OS FreeBSD-12.1
- CUPS-2.3.3
My goal is to get CUPS to listen for TCP/IP connections on 9100, or any arbitrary ip address and tcp port for that matter, passing the incoming RAW spool file to the cups-pdf
filter. After which a cron
job or listener process transfers the resulting files to a WebDAV resource for access.
I would like to accomplish the pdf conversion task entirely within CUPS. I have looked at netcat
and socat
and these may be where I end up. But if it is at all possible to accomplish this with CUPS then I would like to know exactly how one configures a CUPS service to listen on a specific IP address and port; and to route what arrives on that TCP socket to a specific printer.
Is this possible? If so, how is it done?
I was unable to use CUPS for this specific problem. I ended up using a combination of
socat
andgpcl6
.socat
takes the connection and passes it togpcl6
via stdin ( - ).gpcl6
uses thepdfwrite
printer to process the output file. The pdf output file is named with a source tag (external) plus a dynamic timestamp.On the legacy host define a network printer to spool to 192.168.216.179:9100. Send the spool files to convert to pdf to that printer.
Each print job creates its own pdf. The timestamp prevents filename collisions. The gpcl6 -dNOSAFE option is required to allow gpcl6 to write to a file.
I further extended this to provide for PCL3 form overlays and multiple pdfs per spool file. An exmple of this is:
In this example the PCL3 overlay file is picked up by
cat
which prepends it to the spooled data stream and passes that togpcl6
. The-sOutputFile
option ofgpcl6
contains aprintf
format string (%03u) which triggersgpcl6
to break the incoming spool file into individual pdf files at each page break. Depending upon the spool file there may one or two artifacts, a blank sheet or a blank copy of the overlay form, created in addition to the actual documents.The
sed
command strips off leading PCL commands created by the generating host,