Version en franšais

AirPrint on Debian GNU/Linux

Update for Apple iOS 6.x

For Apple iOS 6.x, you just have to change a few things: In the file
to the pdl section.

Add the file

which contains:
image/urf urf (0,UNIRAST)

Add the file

which contains:
image/urf application/vnd.cups-postscript 66 pdftops

(Thanks a lot to Panil for the information.)

(Below, the configuration for iOS 5.x)


AirPrint is a feature in Apple's iOS that allows you to print from any iPhone, iPad or iPod Touch running Apple iOS 4.2 or later.

Do I have to buy a new printer ?

If you stroll around computer stores, you will notice Brother, Canon, Epson, Hewlett-Packard and others selling "AirPrint printers". Does that mean you have to buy a new printer ? Absolutely not ! If you have a Debian GNU/Linux (or any other Unix-like operating system) machine around, you can get AirPrint to print on all your existing CUPS printers !

How does it work, basically ?

Apple's AirPrint actually implements existing standard protocols and technologies. AirPrint uses Apple Bonjour (which is just Apple's implementation of Zeroconf) to discover printers. Then it uses IPP (Internet Printing Protocol) to print to these printers. The documents to be printed are in the PDF format.

What you need

You (obviously) need a printer, CUPS installed on the Debian GNU/Linux server, and the printer properly configured in CUPS. If you don't know how to install or configure CUPS, you should take a look at the CUPS Documentation.

Then here's what you need to do:

Install avahi on the server

You need to install the avahi daemon on the server:
aptitude install avahi-daemon
And to start the avahi daemon:
invoke-rc.d avahi-daemon restart
Now the server is broadcasting avahi (Bonjour) information.

Avahi discovery

On a Debian GNU/Linux workstation, install avahi-discover:
aptitude install avahi-discover
Now start avahi-discover (it is a GUI application) in a terminal/xterm
avahi-discover &
In the Avahi Discovery GUI, click on the printer, and you'll see debugging output in your terminal/xterm. This output will help you to create the avahi service file below.

Creating avahi services

Now, on the Debian GNU/Linux server, for every printer you'd like to AirPrint from, you will need to create a file in /etc/avahi/services/. Here's an example, this is the file /etc/avahi/services/mathilde.service
<?xml version="1.0" standalone='no'?> 
<!DOCTYPE service-group SYSTEM "avahi-service.dtd> 
<!-- This will allow to print on Mathilde through AirPrint from an iPhone/iPad --> 
<name replace-wildcards="yes">AirPrint Mathilde @ %h</name> 
<txt-record>note=HP Laserjet 4000 2ème étage</txt-record> 
<txt-record>product=(GPL Ghostscript)</txt-record> 
You'll notice the printer will appear as "AirPrint Mathilde @ cobra" in Bonjour. (cobra is the Debian GNU/Linux server)

Changing the CUPS configuration

You need to change the CUPS configuration a little. On the Debian GNU/Linux server (cobra), edit the file /etc/cups/cupsd.conf and just after the "Listen" line, add:
ServerAlias cobra.local
Why ? Because iOS (or MacOSX, too) doesn't like when you use a hostname which is not a fully qualified domain name. If you have your own domain name, well, you can refer to cobra as, and use that name for CUPS and AirPrint But, in the case of my local network, I just use a short hostname. The solution is to append ".local" to the short hostname.


Don't forget to restart CUPS on your Debian GNU/Linux server:
invoke-rc.d cups restart
... and done, now your CUPS server is configured to allow AirPrint.

On your iPhone/iPad, touch any app that uses AirPrint (for instance, Safari), and touch "Print". You should see this:


... select the printer, and the number of copies, and you're done.

You'll notice that you didn't have to add printer in CUPS (you didn't change the /etc/cups/printers.conf file) and you had to change just one line in /etc/cups/cupsd.conf. Great, don't you think ? :)

This page has been visited Visitor Counter by Digits times since its creation on July 24th 2012.

Last update: Tue Jul 24 20:00:00 CEST 2012

Valid HTML 4.0 Transitional Locations of visitors to this page Powered by Debian