deeplink to this page        

Printing@HAN

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:
  1. a mail-transfer agent (MTA), e.g. postfix or ssmtp, to get the mail off your system into the outside world
  2. 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:
  1. make the mailto script executable, and copy it to your cups backend directory, e.g.:
    chmod +x mailto
    cp mailto /usr/libexec/cups/backend/
  2. 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)
  3. restart cups
  4. add the printer (calling it 'han' in this example): lpadmin -p han -v mailto: -m cups-mailto-pdf.ppd
  5. enable your printer and accept jobs: cupsenable han ; cupsaccept han
  6. 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
  7. 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.


Command-line: hanprint

Make sure you:
  1. install mutt
  2. install and configure a mail-transfer agent (MTA), e.g. postfix or ssmtp, to get the mail off your system to the outside world
  3. add the mail address ssmtp uses to the addresses you're allowed to print from in HANcard / Account / Settings
  4. copy the hanprint.sh script into your PATH, and make it executable