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!
Thanks. The instructions worked great!!
Thanks, your image worked like a charm! Copy image to SD-Card, boot RPi, open Website add Printer (in my Case Canon Pixma IP4200 driver was already included) and go for it.
In my case the printer prints very slow using AirPrint. RPi is connected via cable and my MacBook has full WLAN signal strength (sitting beside the Router), so it can’t be a bad network connection. Did someone experience that too? Or can someone imagine what the problem could be?
Thanks so far, better slow printing, than no printing (at least considering my iOS devices) ^^
Awesome, been struggling for days to get this to work on my old server, dowloaded your image – ponked it into the PI and was up and running in a couple of minutes – still can’t work out why it won’t work on the old server….but at least our new chrimbo prezzies are printing now 🙂
fantastic. Worked a charm and this was my first attempt with both Raspberry and Linux. Thank you ever so much.
I do have one issue. It was all working fine, I then reset the time location to UK and reset the hostname from ‘raspberrypi’ to ‘AirPrint’ and restarted the hostname service and it was all working (thanks to google for the instructions!). I then shut it down, unplugged the keyboard and monitor and hit it out of sight. Upon booting up, whilst I can SSH onto it, I now cannot see it on my iphone. Any suggestions?
Pingback: Using your RaspberryPI as an airprint server | Garys blog
I would like to download the image, unfortunately it looks like dropbox have disabled the public links. any chance you could send me / update the links?
Thanks in advance.
Hi josh,
That is what happens from time to time, dropbox shuts down my account due to excessive traffic. I’ll let you know as soon as I have a mirror in place.
Regards,
Racer
here is the link for downloading the airprint image from my google drive:
https://drive.google.com/uc?export=download&id=0B92GGEMLt5yZQUxrMjhmVDBtdTQ
Regards,
Racer
Thank your for this great instruction. I got my printer up and running in no-time. One question: I can already use airprint without implementing the instructions in step 9 (avahi and airprint). Can you tell me the functions of the code in that steps? Thank you in advance!
why must using putty? why not direct to rasberry ?
When d/l the original Weezy file mine boot fine, but with yours nothing happes.
I tried to d/l several times.
Any idea? I have a B+ 512MB
Maybe the image I made is to old for the new B+.
Pingback: DIY print server from RPi - About technologies for your home
Hello, I just completed the install on an Raspberry Pi 2 B…works like a champ!
Thanks for the hard work.
Cheers
Danny