Tag Archives: iPhone

How to use your Raspberry Pi as Airprint Server.

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) )

1) Use a fresh wheezy image

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.

Raspi-Config

Enjoy!

Many thx to Lynsay’s Little World

Download your AirPi SD Card image here

*** update – the files have been updated and fit on a 2GB SD cards now ***

The new files can be found in my public Dropbox in the \Images\Airpi directory.

https://www.dropbox.com/sh/cjrcfw49sfc7h8b/SQSjpp8DJG

————————————————————————————————————————————–
I’ve just published a second image for the AirPi. Last month I published an image to get your AirPi working on your Raspberry Pi with a Logilink UA0053 USB soundcard. Now I’ve added on request an image that works with the onboard 3,5mm. For everyone that wants to save the time, you can download the image for a 4GB SD card directly from my public dropbox.Both images are based on Rasbian Wheezy and configured with:
– SSH enabled
– User = pi
– Password = raspberry
– locale = en_US.UTF8
– timezone = Europe.BerlinIt has auto login for user pi enabled
It’s broadcast name is AirPi
Pick the image of your choice. The 2013-03-19-wheezy-airpi image uses the onboard audio jack. The 2013-02-19-wheezy-airpi-UA0053 image is configured to use the USB audio Logilink UA0053 soundcard http://www.logilink.eu/showproduct/UA0053.htm
Write the image to an 4GB SD card with Win32DiskImager.Plug it into the raspberry and hook the raspberry up to your network (and Logilink UA0053 soundcard) and soundsystem. It’ll work like a charm on iOS 6.Enjoy!The files can be found in my public Dropbox.https://www.dropbox.com/sh/cjrcfw49sfc7h8b/SQSjpp8DJG

The broadcast name of the Raspberry AirPi can easily by changed, at the command prompt type:nano /etc/init.d/shairportlook for the following lineDAEMON_ARGS=”-w $PIDFILE -a AirPi”and change AirPi in what ever you like.

ctrl-x and Y to save changes

sudo reboot

ready!

How to change the WLAN settings
WLAN configuration can be set using the following command:
sudo nano /etc/network/interfaces
look for the lines with
wpa-ssid “YOUR SSID”
wpa-psk “YOUR PASSWORD”
and replace YOUR SSID with the SSID of your network and replace YOUR PASSWORD with the password of your network.
ctrl-x and Y to save changes
sudo reboot
ready!
If there is no WLAN connection the Raspberry Pi will use the LAN connection if available.