Making an iPad print to a CUPS queue


Apple’s iPads (really, any recent iOS device - phones, iPods, etc.) use their
“Airprint™” system for discovering and using printers. If you have
something plugged into a Mac (or AirPort), and shared appropriately, this
is all automatic. My printers are all handled by a CUPS server, though, which
isn’t detected by default. Thankfully, this is amazingly easy to set up if
you install Avahi.


Set up Avahi to advertise your printer’s CUPS queue. Basically, you just need
to write an XML description of the service advertisement; mine looks like this:

<service-group>

    <name replace-wildcards="yes">HP Color LaserJet CP2025dn on server</name>

    <service>
    <type>_ipp._tcp</type>
    <subtype>_universal._sub._ipp._tcp</subtype>
    <port>631</port>
    <host-name>server.example.org</host-name>
    <txt-record>txtvers=1</txt-record>
    <txt-record>qtotal=1</txt-record>
    <txt-record>MFG=HP</txt-record>
    <txt-record>MDL=Color LaserJet CP2025dn</txt-record>
    <txt-record>rp=printers/clj2025dn</txt-record>
    <txt-record>note=Den</txt-record>
    <txt-record>product=(HP Color LaserJet CP2025dn)</txt-record>
    <txt-record>Binary=T</txt-record>
    <txt-record>Duplex=T</txt-record>
    <txt-record>pdl=application/pdf,application/postscript,application/vnd.cups-raster,application/octet-stream,image/png,image/jpeg,image/gif,text/plain</txt-record>
    <txt-record>URF=none</txt-record>
    </service>

</service-group>


A couple important points:


  • You must advertise IPP (since that’s CUPS’ native language, this should be obvious).

  • The _universal subtype is required for AirPrint (though OSX will find the printer without this).

  • Printer capabilities are indicated by <txt-record> tags.

  • The pdl record lists all data types the printer (or in this case, CUPS) can natively handle.

  • The URF record is required. It can be equal to “none“, but if this record is missing AirPrint won’t recognize the printer.

  • The “Duplex“ option will make a Duplex option appear in iOS when you try and print to this printer. Other useful boolean options may include:

    • Duplex

    • Copies

    • Transparent

    • Binary






This example is cobbled together from other sources. Ryan Finnie’s blog was
quite useful (http://www.finnie.org/2010/11/13/airprint-and-linux/), as was tjfontaine’s airprint-generate script (https://github.com/tjfontaine/airprint-generate/blob/master/airprint-generate.py).