AirPrint, Ubuntu and a Brother Printer

Hello again,

If you read my last post about using an Ubuntu server as a Time Capsule then you already have most of the key elements to get AirPrint up and running in place. If you don’t need Time Capsule then the pre-requisites are:

  • Avahi
  • CUPS

That’s it. So once you have them installed run through the following steps.

Step 1: Create an Avahi Service File

 sudo nano /etc/avahi/services/printer.service

Step 2: Paste the following into the file

<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
  <name>My Printer</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/My-Printer-CUPS-Name</txt-record>
    <txt-record>ty=My Printer</txt-record>
    <txt-record>adminurl=http://ComputerIP:631/printers/My-Printer-CUPS-Name</txt-record>
    <txt-record>note=My Printer</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>

The text in blue above can be whatever name you want for your printer, those in red have to be exactly as assigned to your printer by CUPS which you can verify from System > Administration > Printing or by navigating to the CUPS admin page (http://computername:631/printers). Everything else should be changed based on your printers settings.

Save and exit the file (CTRL+O then CTRL+X).

Step 3: Ensure the printer you want to use with AirPrint is shared (System > Administration > Printing) and published

Step 4: Edit CUPS config

 sudo pico /etc/cups/cupsd.conf

Step 5: Ensure you have the following settings

ServerAlias *
Port 631
Listen /var/run/cups/cups.sock

Step 6: Restart Avahi and CUPS

sudo restart cups
sudo restart avahi-daemon

And that’s it, you should be able to print from your iPhone or iPad running iOS 4.2.1