Printing from iPad (AirPrint) via CUPS

IOS 4.2 allows Apple IOS devices (iPad, iPhone) to print using a new system called “AirPrint”.  Currently this is only supported by a few select hardware manufacturers, Apple’s own printer simulator applications and printer sharing on Snow Leopard 10.6.5.

This document outlines how to configure CUPS and Avahi to allow printers to show up on IOS devices and allow printing to them.  As a proof of concept cups-pdf was used to create a PDF of the printed document.

Requirements

  • CUPS – www.cups.org, used version 1.3 as version 1.4 seems to have issues with Bonjour sharing.
  • AVAHI – www.avahi.org
  • cups-pdf – http://www.physik.uni-wuerzburg.de/~vrbehr/cups-pdf/
  • Linux – Debian or Centos or anything else really!

Installation

Simple, just follow their instructions, or better yet just use your standard package management suite, as they are all included.

Configuration

Setup CUPS via the GUI, so you have defined a few printers, I created a cups-pdf printer to test with.  The defaults for cups-pdf will be fine for testing. Prints end up in “/var/spool/cups-pdf/”.

Avahi, this may also require DBus (messagebus) to be installed, if you used a package manager then it should have been installed as a dependancy.  Once you have a printer defined in CUPS you are ready to export it to IOS.

create a new file in “/etc/avahi/services” called “playprinter.service”, this file contains an XML description of the printer you wish to export via Bonjour.  Below is my Sample file:

 




<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
 <name>Play Printer</name>
<service>
<type>_ipp._tcp</type>
<subtype>_universal._sub._ipp._tcp</subtype>
<port>631</port>
<txt-record>txtver=1</txt-record>
<txt-record>qtotal=1</txt-record>
<txt-record>rp=printers/PDF</txt-record>
<txt-record>ty=Play Printer</txt-record>
<txt-record>adminurl=http://printers.00:631/printers/PDF</txt-record>
<txt-record>note=Super Space</txt-record>
<txt-record>priority=0</txt-record>
<txt-record>product=virtual Printer</txt-record>
<txt-record>printer-state=3</txt-record>
<txt-record>printer-type=0x801046</txt-record>
<txt-record>Transparent=T</txt-record>
<txt-record>Binary=T</txt-record>
<txt-record>Fax=F</txt-record>
<txt-record>Color=T</txt-record>
<txt-record>Duplex=T</txt-record>
<txt-record>Staple=F</txt-record>
<txt-record>Copies=T</txt-record>
<txt-record>Collate=F</txt-record>
<txt-record>Punch=F</txt-record>
<txt-record>Bind=F</txt-record>
<txt-record>Sort=F</txt-record>
<txt-record>Scan=F</txt-record>
<txt-record>pdl=application/octet-stream,application/pdf,application/postscript,image/jpeg,image/png,image/urf</txt-record>
<txt-record>URF=W8,SRGB24,CP1,RS600</txt-record>
</service>
</service-group>



The things of note which the IOS devices are checking for are the “subtype”, which allows it to show up, and the “adminurl” and “rp” which tells IOS where to send the print job.  The rest of this XML should be fairly similar to other Bonjour items.

 

You can use a “Bonjour Bowser” to see what is been broadcast on the network.

 

Restart avahi (Not always necessary), you should now be able to see your printer on your IOS device and send a print job to it.

 

Note, the IOS device does not have a driver for the printer and never will, so CUPS will have to perform an driver and filter support necessary to get a nice print job.  Refer to CUPS documentation for details of setting that side of it up.