Printing from iPad or iPhone via AirPrint and CUPS

Printing on Air

Article from Issue 154/2013

If your home network includes a Linux machine, you have access to everything you need to share your printers on the network as AirPrint-enabled devices.

Version 4.2 of iOS was the first to give the Apple iPad and iPhone the ability to print – but only on printers that support the technology known as AirPrint [1]. AirPrint devices are now available from all major manufacturers in every price and performance class, but many users are still wary of having to buy a new printer just to put something from their iPhone or iPad onto paper.

Luckily, if your home network includes a Linux machine, you have access to all the tools you need to share your printers on the network as AirPrint-enabled devices. AirPrint is based on the zero-configuration (Zeroconf) networking standard [2], which Apple markets under the brand name Bonjour. Linux has its own implementation of Zeroconf known as Avahi [3].

As early as 2011, Till Kamppeter modified the Common Unix Printer System (CUPS) implementation for the Ubuntu "Natty" and "Oneiric" versions so that connected AirPrint printers are directly available [4]. If your distro doesn't support direct configuration, it pays to know how to set up AirPrint support manually. In this article, I take a look at AirPrint with Linux.


AirPrint is a technology that lets the device send PDF files to the printer. For this purpose, it sends information about the number of copies and page numbers that the user actually wants to print. A working installation of CUPS should be all you need to let iPad and iPhone find the network-shared printers and print to them.

Unfortunately, Apple has now removed some important features from CUPS that are not necessary on Mac OS X, because they are provided there by the Bonjour service [5]. Fortunately, Linux reintroduces these missing features through Avahi, which includes the necessary functions.

CUPS configuration in Linux is described by numerous web sources [6]. In this article, I assume a working version of CUPS is running on your system. Once the CUPS service is running, first check whether your printer is working by printing a test page. (Open a browser and enter the URL http://<hostname>:631.) You can reach this page from any other computer on the network. In the Printers tab below Management, you will see the command for outputting the test page.)

To share the printer on the network, make sure the /etc/cups/cupsd.conf file contains the appropriate entries. Listing 1 shows an example from the test system. The first two lines are important here; they allow any client to access the server. These lax permissions facilitate attacks on the service. It is thus important to consider any changes you make.

Listing 1

Example of /etc/cups/cupsd.conf


Change the file accordingly and restart the CUPS system. On openSUSE, you can do the following:

sudo systemctl restart cups.service

On Ubuntu and other Debian systems, however, use the following command:

sudo /etc/init.d/cups restart

Now you should be able to find the printer from a Windows computer. To do this, Add a new network printer in the Control Panel and then type the address of the CUPS server and the name of the printer as the name of the shared printer (Figure 1).

Figure 1: If you additionally want to use the shared printer on Windows, set up a new network printer on the system in question.

Windows asks for the printer model to install the correct driver. If you see an Unable to connect message here, check your CUPS installation and the network share for the printer again.


For Apple devices to be able to recognize the printer, you need to advertise it via a Bonjour broadcast on the network. To do this, set up an Avahi service. The configuration files for these services can be found in the /etc/ahavi/services directory. Listing 2 shows the AirPrint HP1220C.service file on our lab system.

Listing 2

AirPrint HP1220C.serviceconf


Admittedly, creating and modifying these service files manually for each printer on the system might not be everybody's idea of fun. Luckily, developer Timothy J. Fontaine implemented a small Python script (Listing 3), that automatically creates these files for all CUPS printers on the system [7].

Listing 3

Executing Python Script

unzip master
cd tjfontaine-airprint-generate-fb98c1d/
mv AirPrint-HP1220C.service /etc/avahi/services
sudo systemctl restart avahi-daemon.service
sudo systemctl restart cups.service

The steps are easy enough: Just run the script without any parameters once for each printer; this gives you a file that you then copy to the /etc/avahi/services directory. After restarting Avahi and CUPS, you should be able to print from Apple devices without any problems.

Creating MIME Types

What we have looked at thus far will fail if you happen to have iOS version 6 or newer installed on your device. In this case, you also need to create new MIME types to associate incoming data correctly. This is fairly straightforward (Listing 4).

Listing 4

Creating MIME Types

echo "image/urf urf string(0,UNIRAST<00>)" > /usr/share/cups/mime/airprint.types
echo "image/urf application/pdf 100 pdftoraster" > /usr/share/cups/mime/airprint.convs

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • CUPS 1.4.0 with DDK and Improved Bonjour

    The common Unix printing system (CUPS) is now available as version 1.4.0. In addition to a variety of improvements, the free print server now includes the driver development kit (DDK).

  • Make Your Printer Smarter

    Niche hardware from the olden days does not always embrace the network. Attaching a Raspberry Pi or other single board computer can add lots of new functionality.

  • Printing Proper

    One last step remains in our 3D-printing voyage: actually printing something. This issue, we'll tackle how to print and monitor your print at the same time.

  • Ubuntu 17.10

    Ubuntu is back to the first letter of the alphabet – and back to the Gnome desktop. But you'll also find lots of new stuff in the latest release.

  • Chrome OS to Print Through Cloud

    Drivers, be gone.

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More