AirPrint is a recent feature for the iPhone and iPad. This allows remote printing and other nifty features. Out of the box Avahi and CUPS do not publish printers is a compatible fashion. Here are some simple steps to enable these features and print from your mobile.

Requirements

On Praxis/Gentoo system these the minimum requirements. You may need/want to enable the X,python,qt4,&c flags, depending on your environment.

root@host ~ # emerge -pv cups avahi

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild   R   ] net-dns/avahi-0.6.25-r1  USE="-autoipd -bookmarks dbus -doc gdbm -gtk -howl-compat ipv6 mdnsresponder-compat -mono -python -qt4 -test" 0 kB
[ebuild     U ] net-print/cups-1.3.11-r3 [1.3.11-r2] USE="-X acl avahi dbus gnutls -java jpeg -kerberos -ldap pam perl -php png -ppds python -samba -slp ssl -static tiff -xinetd -zeroconf" LINGUAS="-de -en -es -et -fr -he -id -it -ja -pl -sv -zh_TW" 0 kB

Configuring AirPrint in Avahi

It is assumed that Avahi and CUPS are previously installed and functioning and that at least one printer is advertised by CUPS.

  1. Browse/Discover the CUPS using avahi-browse or avahi-discover. Running avahi-browse from the command line will generate something like this:
    root@host ~ # avahi-browse --terminate --resolve _ipp._tcp
    
    = eth0 IPv4 Dell Laser Printer 1710 @ host.edoceo.lan   _ipp._tcp            local
       hostname = [host.edoceo.lan]
       address = [10.0.0.6]
       port = [631]
       txt = ["pdl=application/pdf,application/postscript,application/vnd.cups-raster,application/octet-stream,image/png" "Binary=T" "Transparent=T" "printer-type=0x3006" "printer-state=3" "product=(Lexmark E321)" "note=Office" "ty=Lexmark Optra E321 Foomatic/ljet4" "rp=printers/Dell_1710" "qtotal=1" "txtvers=1"]
    
    For an X environment use avahi-discover to browse and select the printer.
  2. This outuput is copied to an Avahi service file as follows.
    root@host ~ # cat /etc/avahi/service/airprint-dell-1710.service
    <?xml version="1.0" standalone='no'?>
    <!DOCTYPE service-group SYSTEM "avahi-service.dtd">
    <service-group>
    <name replace-wildcards="yes">AirPrint Dell 1700 @ %h</name>
    <service>
           <type>_ipp._tcp</type>
           <!-- This is key for AirPrint -->
           <subtype>_universal._sub._ipp._tcp</subtype>
           <port>631</port>
           <!-- These are copied from the txt portion of the above output -->
           <txt-record>txtvers=1</txt-record>
           <txt-record>qtotal=1</txt-record>
           <txt-record>rp=printers/Dell_1710</txt-record>
           <txt-record>ty=I make the printer Go</txt-record>
           <!-- This is visible in iPhone UI -->
           <txt-record>note=I am an AirPrint Printer</txt-record>
           <txt-record>product=(GPL Ghostscript)</txt-record>
           <txt-record>printer-state=3</txt-record>
           <txt-record>printer-type=0x3006</txt-record>
           <txt-record>Binary=T</txt-record>
           <txt-record>Transparent=T</txt-record>
           <txt-record>URF=none</txt-record>
           <txt-record>pdl=application/pdf,application/postscript,application/vnd.cups-raster,application/octet-stream,image/png</txt-record>
    </service>
    </service-group>
    The txt section is replayed in this configuration file, Avahi will automatically load this once the file is saved.
  3. Now it is possible to browse for the _universal services.
    root@host ~ # avahi-browse -rt _universal._sub._ipp._tcp
    
    + eth0 IPv4 AirPrint Dell 1700 @ carbon                   _ipp._tcp            local
    = eth0 IPv4 AirPrint Dell 1700 @ carbon                   _ipp._tcp            local
       hostname = [carbon.edoceo.lan]
       address = [10.0.0.6]
       port = [631]
       txt = ["URF=none" "pdl=application/pdf,application/postscript,application/vnd.cups-raster,application/octet-stream,image/png" "Copies=T" "Duplex=F" "Binary=T" "Transparent=T" "printer-type=0x3006" "printer-state=3" "product=(GPL Ghostscript)" "note=Printer on Carbon, is it on?" "ty=I make the printer Go" "rp=printers/Dell_1710" "qtotal=1" "txtvers=1"]
    
  4. See Also