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
/etc/avahi/services/myprinter.service
add
image/urf
to the pdl section.

Add the file

/usr/share/cups/mime/apple.types
which contains:
image/urf urf (0,UNIRAST)

Add the file

/usr/share/cups/mime/local.convs
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)

Introduction

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 --> 
<service-group> 
<name replace-wildcards="yes">AirPrint Mathilde @ %h</name> 
<service> 
<type>_ipp._tcp</type> 
<subtype>_universal._sub._ipp._tcp</subtype> 
<port>631</port> 
<txt-record>txtvers=1</txt-record> 
<txt-record>qtotal=1</txt-record> 
<txt-record>rp=printers/mathilde</txt-record> 
<txt-record>ty=Mathilde</txt-record> 
<txt-record>adminurl=http://cobra:631/printers/mathilde</txt-record> 
<txt-record>note=HP Laserjet 4000 2ème étage</txt-record> 
<txt-record>product=(GPL Ghostscript)</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>Duplex=T</txt-record> 
<txt-record>Copies=T</txt-record> 
<txt-record>pdl=application/pdf,application/postscript,application/vnd.cups-raster,application/octet-stream,image/png</txt-record> 
<txt-record>URF=none</txt-record> 
</service> 
</service-group>
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 cobra.example.com, 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.

Done

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:

AirPrint

... 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