Saturday, June 30, 2012

iPrint: Printing from iPhone to Ubuntu 10.04 Brother MFC 210c printer


So, there was a need to print something at home. Needless to say, this could've been done from either the Windows Vista laptop or Ubuntu desktop, or the Mac Book Pro. But since there were iPhones and iPads also in the mix, the challenge was to print the email directly from the palm of my hand (the Palm WebOS device is being obsoleted, much to my chagrin).


The curious fact is, I never felt motivated enough to do this for the WebOS device, though it must've been entirely possible. Oh well, I guess that's an argument in favor of market share and ecosystems.

But I digress. So, with a little bit of web searching, I came across the following excellent posts that allowed me to get started, and then with a little bit of tinkering, I managed to print from the iPhone. Yay!


Setup:

a) Brother MFC 210C connected to
b) 2.4 GHz P4 dual core with HT tower running Ubuntu 10.04, connected to the rest of the home network via
c) Linksys WRT54G running DD-WRT in bridge mode
d) iOS devices supporting print option (iPhone 4S) connected to the network via WiFi


I already had cups installed and setup and the printer working. The printer is also shared via Samba so that the win machines can get to it. This made life simpler in some measure.



bash# dpkg -s cups | grep Status

Status: install ok installed
I had to install a pdf filter:
bash# sudo apt-get install cups-PDF
I also had the avahi-daemon up and running
bash# dpkg -s Avahi-daemon | grep Status
Status: install ok installed


Modify cups settings as below:



bash# sudo vi /etc/cups/cupsd.conf


Add the line

ServerAlias *

Change the following lines:

Port Localhost:631 to Port 631
BrowseAllow to BrowseAllow All



Downloaded the excellent python script for generating the Avahi configuration scripts



bash# cd ~/temp
bash# wget https://raw.github.com/tjfontaine/airprint-generate/9d329cfc319e9d7c2eca53192411bf746a7b73d1/airprint-generate.py



run the script


bash# python airprint-generate.py

copy the generated file to avahi daemon settings


bash# sudo cp AirPrint-MFC210C.service /etc/avahi/services/


restart services
bash# sudo /etc/init.d/cups restart

bash# sudo restart avahi-daemon



At this point, I was able to see the Printer, but when I tried to print to it, nothing happened.

Time to play with Ubuntu CUPS settings.


6. Point browser to http://localhost:631, ensure that the following settings are set:

“Save debugging information for troubleshooting”.
Click “Change settings”
Click “View Error Log”
I saw the following errors:
E [24/Feb/2012:00:27:44 -0800] Unable to remove temporary file "/var/spool/cups/tmp/.fontconfig" - Is a directory
E [24/Feb/2012:00:27:44 -0800] Unable to remove temporary file "/var/spool/cups/tmp/.hplip" - Is a directory
These files are owned by “lp”, so to delete them
bash# sudo su lp
bash# pushd /var/spool/cups/tmp
bash# rm –fr .hplip .fontconfig
Ensure that cups settings match below (“Show printers…”)

Click change settings
Print from iPhone!

Note that this will overwrite the earlier generate cupsd conf file. The settings will remain the same, only that the format would probably change.
KNOWN ISSUES
Need to keep restarting avahi daemon
sudo restart avahi-daemon
I haven’t looked in to why this is happening, but I can print for the time being!

References:
Confounded Technology's excellent post
Awesome airprint config file generating script that tjfontaine authored
CUPS printing basics and background
Ryan Finne's original work that kick-started all of this

No comments: