Make Any Printer AirPrint-compatible on FreeBSD

AirPrint is a cool technology, but what if you have printers that aren’t officially supported?  Here’s how to make it work.  Note that this was done on FreeBSD 10.1.  This may work on other operating systems, but package installation and filesystem paths will be different.

Install cups via ports, I selected both Python and Perl bindings, and Avahi for advertisement (since we’ll be using Avahi to advertise the services anyway):

portmaster -dbH print/cups print/hplip

After going through the various package configurations, grab a cup of coffee because there are many dependencies to install.

Enable cups:

sysrc cupsd_enable=YES

Set up cupsd.conf.  Note that this isn’t the most secure configuration, if this system is on the internet, please make adjustments accordingly.

SystemGroup sys root
# Allow remote access
Port 631
Listen /var/run/cups/cups.sock
Browsing On
BrowseLocalProtocols dnssd
DefaultAuthType Basic
WebInterface Yes
FileDevice Yes
ServerAlias *
DefaultShared yes
DefaultEncryption Never

  # Allow remote access...
  Order allow,deny
  Allow all




  AuthType Basic
  Require user @SYSTEM

Start cups:

service cupsd start

Head over to http://[IP]:631 and set up your printer.  This varies by printer, so I’ll leave this up to you.  Make sure to print a test page to ensure that cups itself is working.

Next, let’s add the needed AirPrint MIME types:

echo "image/urf urf string(0,UNIRAST<00>)" > /usr/local/share/cups/mime/airprint.types
echo "image/urf application/vnd.cups-postscript 66 pdftops" > /usr/local/share/cups/mime/airprint.convs

All that’s left to do now is add the actual services to Avahi.  We’re going to run a Python script that does this, but first, I had to add the cups package to Python manually.  You may not need to do this:

CPATH=/usr/local/include pip install pycups

Download airprint-generate.py:

fetch https://raw.githubusercontent.com/tjfontaine/airprint-generate/master/airprint-generate.py

I modified airprint-generate.py based on a forum post, I am not sure if this is needed, but it doesn’t appear to hurt: In the section setting ‘DOCUMENT_TYPES’, add a new line just under “‘application/postscript’: True,” that says “‘application/vnd.cups-postscript’: True”.

Next, run it:

python airprint-generate.py

This will create a .service file in the current directory for each of the printers you have set up in CUPS.  Put these service files into the Avahi service directory:

mv *.service /usr/local/etc/avahi/services

Finally, restart avahi-daemon:

service avahi-daemon restart

At this point,  you should be able to AirPrint from your iOS devices.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.