Today, I was reading a PDF on my iPad and wanted to print a page from the PDF document on my printer, but Apple only supports printing to Airprint printers. So, no luck with my Samsung SCX-4824FN, or…..
With some google-ing I found a way to turn the Raspberry-Pi into an Airprint server. The Airprint server connects to your non-Airprint printer via USB or network-connection and gives your Apple device (iPhone or iPad) access to it. It works marvelous!
I used the instructions from this website.
In summary:
(click here or here you want to skip the work and just download the SD-Card image, you will need a PPD for your printer as well (see text below) )
2) connect to the raspberry pi via SSH
standard credentials are user: pi password: raspberry
3) switch to admin: sudo su
4) update, upgrade & install packages
sudo aptitude update
sudo aptitude upgrade
sudo aptitude install avahi-daemon
sudo aptitude install avahi-discover
sudo aptitude install libnss-mdns
sudo aptitude install cups
sudo aptitude install cups-pdf
sudo aptitude install python-cups
5) start services
sudo usermod -aG lpadmin pi
sudo /etc/init.d/cups start
sudo /etc/init.d/avahi-daemon start
6) Now edit the CUPS configuration file
sudo nano /etc/cups/cupsd.conf
You’ll need to set-up the listeningport. Comment out the line that reads “Listen localhost:631″. Add in “Port 631″. It should look like this:
#Listen localhost:631
Port 631
CUPS must be configured to work with any hostname, so it functions with AirPrint. The ServerAlias * directive needs to be added before the first occurence of <Location />. It should look like this:
# CUPS to work with any hostname
ServerAlias *
The config file must also be edited for enabling local access to the server by adding “Allow @Local” This must be done in the following three areas of the config file:
# Restrict access to the server…
# Restrict access to the admin pages…
# Restrict access to configuration files…
then save the config file (ctrl-x and Y)
7) restart the service
sudo /etc/init.d/cups restart
8) CUPS configuration
PPD
before you start this step, make sure that you have the PPD (Postscript Printer Description) for your printer. I had trouble at first finding the PPD for my Samsung printer but it appeared to be included in the UnifiedLinuxDriver package which can be downloaded from the Samsung website. I only needed to unzip the UnifiedLinuxDriver_1.00.tar.gz and browse to the PPD directory. The PPD can stay on your windows / linux machine as it will be uploaded via the CUPS web interface later on.
Navigate the the CUPS configuration page by typing the IP address from your Raspberry Pi in your browser + the CUPS port number (so it’ll be an address like 192.168.xxx.xxx:631). A security exception message may pop up but that’s ok. Continue onwards!
Plug your printer into one of the USB ports of the Raspberry Pi or use a network printer on the same network of the Raspberry Pi. Click “add printer” (At this stage, you might be asked for the username (Pi) and password (Raspberry) of the Raspberry Pi.) in the CUPS web interface and it should appear in the list of available printers. You’ll have to fill in details for the printer, such as name and location. You can enter whatever you want in here but the important part is ensuring you tick the “share this printer” box. Following this, you’ll have to select the appropriate printer driver from a (large) list that appears or use a PPD. Enter print and paper settings too. You’re now ready to click on maintenance > print test page. If everything has gone to plan, the test page will print successfully.
Now, click on the Admin tab and view the server settings which are towards the right-hand side of the screen. Tick the box that says “share printers connected to this system”.
9) Setup Avahi service
cd ../../opt
sudo mkdir airprint
cd airprint
sudo wget -O airprint-generate.py –no-check-certificate https://raw.github.com/tjfontaine/airprint-generate/master/airprint-generate.py
sudo chmod 755 airprint-generate.py
sudo ./airprint-generate.py -d /etc/avahi/services
10) create Airprint files
cd /usr/share/cups/mime
sudo nano airprint.types
#
# “$Id: $”
#
# AirPrint type
image/urf urf string(0,UNIRAST)
#
# End of “$Id: $”.
#
ctrl-x and Y to save
sudo nano airprint.convs
#
# “$Id: $”
#
# AirPrint
# Updated list with minimal set 25 Sept
image/urf application/pdf 100 pdftoraster
#
# End of “$Id: $”.
#
ctrl-x and Y to save
sudo service cups restart
11) And finally the last commands
cd
cd ../../opt/airprint
sudo wget https://raw.github.com/tjfontaine/airprint-generate/master/airprint-generate.py
sudo ./airprint-generate.py -d /etc/avahi/services
sudo reboot
And for everybody that wants to save time, you can download an image for a 2GB SD Card from my public dropbox look for the following file 20130502 Wheezy with Airprint 2GB.zip in \images\Airprint\. Alternatively you can download it from google drive.
It is probably best to install the image onto a 4GB (or larger) SD-Card. Be sure to run sudo raspi-config the first time in order to expand the file system, to make full use of the available space.
Enjoy!