For those of you that have upgraded to iOS 6, you may have discovered that my AirPrint tutorial no longer works. This results from the fact that URF is the required format, and the PDF container relied on previously cannot render pages from an iOS 6 device. To fix this you need to compile the urftopdf filter for CUPS and modify your AVAHI configuration accordingly.

Let me preface this by saying these instructions assume Ubuntu Server. Additionally, unlike my previous instructions this does require development tools and a little bit more hacking.

1. Install Pre-Requisits. You are going to need to compile a filter for CUPS; to do this the libcups library is required. Unfortunately, this cannot currently be installed directly using the CUPS development libraries for Ubuntu as a result of a downstream dependency error. However, the Linux Standard Base (LSB) libraries will include this for you:

apt-get install build-essential
apt-get install lsb-build-base3

After installing, you will need to fake out the cups include directory:

$ cd /usr/include
$ ln -s lsb3/cups .

Finally, the library version is currently at 2 which requires another tweak so that we can link directly:

$ cd /usr/local/bin/
$ ln -s libcups.so.2 libcups.so

2. Install libHaru. This is a PDF library and can be downloaded from http://libharu.org/wiki/Downloads. It can be easily compiled and installed on Ubuntu, you may cut and paste the following and execute at a command prompt:

$ wget http://libharu.org/files/libharu-2.2.1.tar.gz
$ tar zxvf libharu-2.2.1.tar.gz
$ cd libharu-2.2.1/
$ ./configure && make
$ sudo make install

3. Download urftopdf and compile. This is the most critical part, and is contingent on the previous steps. You can find this on GitHub at https://github.com/superna9999/urftopdf or you may refer to the following:

$ git clone https://github.com/superna9999/urftopdf.git
$ cd urftopdf
$ make
$ sudo ./install_pdf.sh

During the build process, pay particular attention to the output of make. Since there is no standard configuration script, any kind of build failure presents itself here; this is a typical result of compiling urftopdf on an x86_64 Ubuntu server with Linux kernel 2.6.32:

$ make
cc urftopdf.c -lhpdf -lcups -o urftopdf -lm
urftopdf.c: In function ‘main’:
urftopdf.c:327: warning: comparison between pointer and integer

4. Update URF Text Record in AVAHI Printer Configuration. In your AVAHI printer configuration file(s), either update or add the following <txt-record/>

<txt-record>URF=W8,SRGB24,CP1,RS600</txt-record>

In most cases, your AVAHI printer definitions can be found in /etc/avahi/services.

5. Update MIME Type in AVAHI Printer Configuration. Within the same printer configuration file(s), ensure the following record exists with these MIME types:

<txt-record>pdl=application/octet-stream,application/pdf,application/postscript,image/gif,image/jpeg,image/png,image/tiff,text/html,text/plain,application/openofficeps,application/vnd.cups-banner,application/vnd.cups-pdf,application/vnd.cups-postscript,image/urf</txt-record>

6. Restart CUPS and AVAHI.

That should do it. From your iOS 6 device the printers on your Linux server will be visible and you can once again print. As previously noted, this has the added benefit that the AirPrint devices can also be shared with your Mac OS X computers.

 

Categories: AppleUbuntu

15 Comments

Eric Katz · October 9, 2012 at 5:23 pm

Works!!!

Rainer Buchholz · December 6, 2012 at 11:48 am

Thanks for your work.

Vincent Philion · January 29, 2013 at 6:49 pm

Hi! I tried to run your code, but I get this as a result of make =

/usr/bin/ld: cannot find -lcups
collect2: error: ld returned 1 exit status
make: *** [urftopdf] Error 1

Can you help me? many thanks in advance!
Vincent

    Eric Sarjeant · March 4, 2013 at 8:03 pm

    I had replied to this previously, but it looks like it didn\’t make it. Here goes again…

    It’s trying to link to the cups library but it’s not there. The lsb-build-base should include this but if you’re on an older version of Ubuntu you may want to try:

      sudo apt-get install libcups2-dev

    Let me know if that works. Also, be sure to follow my other steps from the previous write-up on AirPrint with iOS5 devices.

Sebastian Ryborz · January 31, 2013 at 2:33 am

Thank you!
Finally your post help me setting up cups with airprint-option on a raspberrypi (running raspbian – debian wheezy), though in my special case adjusting the avahi configuration as you described it and installing libharu did it (urftopdf wasn\’t necessary).

John Earnshaw · March 4, 2013 at 9:37 am

hi, will this still work with iOS<6? I have an iPad 1 and an iPad 4 and would like to print from both

    Eric Sarjeant · March 4, 2013 at 8:01 pm

    This should work with with anything from iOS 4.2 onwards; which would cover any iPad or just about iPhone from 3GS on up.

Ton Amsterdam · November 14, 2013 at 6:03 am

Does it still work with IOS7?

    Eric Sarjeant · November 14, 2013 at 8:44 pm

    Yes – this works with iOS7. The latest version of netatalk does generally make all of this much easier to setup. I am currently running v3.0.4 and am extremely pleased with all aspects of this, including print and TimeMachine support on Linux.

      Ton Amsterdam · December 1, 2013 at 12:17 pm

      Many thanks for your response.

      Today I finally had time to connect my HP Deskjet 990C to my Ubuntu box. The printer got recognised and via the GUI I selected to share and announce the printer. Printing from my MacBook was never so simple, in the add printer dialog the printer was visible (via bonjour). Double clicking it was enough to make it work.

      Then I tried printing from my Iphone 4s running IOS 7. Also there the printer was seen. I didn\’t expect it to work, since I didn\’t any filters and such yet. But it does work. First I tried to print a mail, then I also tried to print a photo. Both where printed nicely.

      Running Ubuntu 12.04.3 LTS.

        Eric Sarjeant · December 2, 2013 at 9:26 pm

        That\’s good to know, I should probably update my site to reflect the excellent support v3 is offering. Configuration is much easier than before, and the need for much of these manual tweaks has gone away.

Ean Price · November 25, 2013 at 6:10 am

Fantastic! Thanks for putting this together. FYI I was able to get it running on CentOS 5 and OpenBSD 5.4 as well.

Brian Hechinger · May 7, 2014 at 10:04 am

These directions don\’t seem to entirely work with Ubuntu 14.04 for me.

Specifically Steps 4 and 5.

The directory /etc/avahi/services exists but there is nothing there to edit so I\’m not entirely sure what I should be doing!

    Eric Sarjeant · May 18, 2014 at 8:25 am

    Check out my other article on Netatalk 3.0, you\’ll probably just need to update /etc/afp.conf to configure your AFP server. Everything goes in here now, the services used in previous releases will rollup into this fie.

Comments are closed.