AirPrint on Ubuntu

How to print from iPhone/iPad (iOS 4.2) via Ubuntu

I just noticed that with the latest 10.6.5 update, Apple at the last minute disabled support for printing from iOS 4.2 devices to shared printers in OSX. Instead of trying to overwrite new drivers with prerelease versions, I thought that there must be someone, somewhere out there who has figured out how to do this using the fine, free tools available to us. I like open standards, open tools, open source.

From what I understand AirPrint supports printing two ways:

  • Via officially-supported HP ePrint printers that advertise themselves on your subnet
  • Via shared printers from Mac/Windows (this is the part that apparently got axed, at least in the latest 10.6.5 update… don’t know how Windows will fare)

I don’t have a new HP ePrint printer, but I do have a wonderful Ubuntu 10.04 server running avahi (open source Bonjour/mDNS responder)… I wonder if there’s a way to have my server act as an AirPrint device and then send the print job to my networked printer?

Enter this post. Excellent! Set up a Bonjour service, point it to a shared printer, done!

Here’s what I had to do in Ubuntu  to get printing to work, YMMV:

  • Install my printer (networked HP Color LaserJet 1515n) using the graphical configuration utility (System->Administration->Printing). Make sure the printer is shared.
  • Updated my /etc/cups/cupsd.conf configuration to allow network access (default Ubuntu configuration is for localhost only):
    # Only listen for connections from the local machine.
    #Listen localhost:631
    #Listen /var/run/cups/cups.sock
    Port 631
    ServerAlias *
    
    
    and
    
    
    # Restrict access to the server...
    <Location />
    Order allow,deny
    Allow @LOCAL
    </Location>
    
  • Tested remote access to Ubuntu's cups web GUI from my laptop (to make sure machines other than the Ubuntu server had access to cups): http://172.16.0.50:631/printers/
  • Tested that I could print remotely from my laptop to the new shared printer on Ubuntu (simple "Add Printer" in OSX and then print test page)
  • Configured avahi with a new printer service /etc/avahi/services/printer.service. As mentioned in the original link, rp and adminurl are the most important configuration bits.
    <?xml version="1.0" standalone='no'?><!--*-nxml-*-->
    <!DOCTYPE service-group SYSTEM "avahi-service.dtd">
    <service-group>
      <name>HP 1515n</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/hp-cp1515n</txt-record>
        <txt-record>ty=HP 1515n</txt-record>
        <txt-record>adminurl=http://172.16.0.50:631/printers/hp-cp1515n</txt-record>
        <txt-record>note=HP Color LaserJet cp1515n</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>
    
  • Printed a page from iOS simulator
  • Printed a page from iPhone 3GS with iOS 4.2.1:
  • Done!

I'm not sure if all printers will work out of the box with this configuration, but since my printer supports PostScript I assume it can rasterize pretty much anything iOS will send it. In any case, I didn't have to configure any filters or print settings. It just worked. Hopefully Apple won't further cripple AirPrinting by also "patching" iOS so that only HP ePrint devices are supported and it no longer recognizes Bonjour services with subtype _universal._sub._ipp._tcp. We'll see what happens!

Now all I need is an iPad. And a reason to print.

Updated 2010-11-21: repaired some mangled XML due to WordPress's less-than-nice HTML-parsing

Updated 2010-11-23: added post subtitle, added screenshot from iPhone

17 comments

  1. OSxMobile

    This tutorial has helped me very, very much. Thanks!
    The only downside: my print job takes up to 5 minutes to be processed.
    But, at least I’ve got it working finally!

    • David

      Glad it helped! I think the print time can be affected by the print driver (in Ubuntu/cups) and the type of printer you have (does it have its own processor+memory, or is it host-based, etc). Maybe try using another driver? In my case, I am lucky: my printer churns out a page from iPad/iPhone pretty much instantly. I’d recommend a bit of googling to find a decent solution for your problem. :)

  2. Anders

    Thanks for an excellent tutorial. I also have the CP1515n and a 9.10 32-bit Ubuntu box; can confirm that this works without any delays. CUPS is apparently version 1.4.1.

  3. Pingback: AirPrint to an Ubuntu shared printer via CUPS « Kimptoc
  4. david M

    So you need two linux boxes? I currently have a linux debian samba server at home and a hacked router running Optware running my phone server. Seems like this project is very doable. Is it possible to have samba and cups and avahi running on the same box? Any advice in my case?
    Thanks.

    • David

      Hi! No, you don’t need two boxes. Samba, cups and avahi can be all run on the same machine–that’s how my Ubuntu machine was configured (except I had afpd instead of samba).

  5. Pingback: Install AirPrint On Ubuntu Sever 8.04 - Justin Walker
  6. Hilary B. Bisenieks

    I’ve run into the problem of my iPad not being able to discover the printer I have set up on my 12.04 workstation, though I suspect that it’s to do with the fact that the workstation is on a separate VLAN from the iPad. I’ve got the reflector option turned on in avahi-daemon.conf, but that’s more of a blind hope thing, since my workstation isn’t our firewall (thank goodness), so there aren’t multiple VLANs going through it. I’ll be repeating my experiments with the workstation on the same VLAN as the wireless for the iPad and see what comes of it.

    Thanks for the great information regardless.

  7. Pingback: AirPrint, Ubuntu, and You (and Your iPad) « Beep Boop
  8. Pingback: Install AirPrint On Ubuntu Server 8.04 - Justin Walker

Post a comment

You may use the following HTML:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>