In the days before cubicles, we had our own printer, which could be easily accessed in CUPS.
These days, life isn't as easy, but the
follow-me printing
used now allows the sending of files to the printer as email attachments.
The script hanprint below allows you to do
this from the command line, but using the
CUPS-mailto backend is more
comfortable, since you can print from any program (including the command
line) and select a page range rather than send an entire PDF file.
CUPS mailto
You will need:
a mail-transfer agent (MTA), e.g.postfix or
ssmtp, to get the mail off your system into the outside world
cups-mailto:
the mailto script,
pdf.ppd,
and, if you haven't got a script to convert postscript to pdf yet, pstopdf
(in my case, everything works without the latter, though I'm not sure how...
If it doesn't for you, copy it into your system path and make it executable)
Then:
make the mailto script executable, and copy it to your cups backend directory, e.g.:
chmod +x mailto
cp mailto /usr/libexec/cups/backend/
copy the printer driver into its cups directory, for example:
cp pdf.ppd /usr/share/cups/model/cups-mailto-pdf.ppd
(I renamed it to show the file's origin)
restart cups
add the printer (calling it 'han' in this example):
lpadmin -p han -v mailto: -m cups-mailto-pdf.ppd
enable your printer and accept jobs:
cupsenable han ; cupsaccept han
since I'm not sure how to pass options to lp, I added the from and
to addresses manually to the mailto backend:
mailfrom = "my_sender_address_that_is_accepted_by_han_print@server.com" mailto = "print@han.nl" Do this just before the line "msg = MIMEMultipart()", and without indentation
for a better experience, replace the "Manufacturer" line in the .ppd
file with something like
*Manufacturer: "CUPS mailto PDF"
That should be all. For testing, you may want to replace the print@han.nl
address in the mailto line in the mailto script with your own email
address — upon printing, you should receive an email with a pdf
attachment. The HAN printer will print the attachments only, so there's no
need to worry about weird content or subject lines.