As a $35 pc with very low power requirements, the Raspberry Pi is uniquely suited to serve many different purposes especially as an always-on low power server. When I first heard of the Pi, I was excited because I wanted it to become an AirPrint Server. This allows Apple’s iOS line of devices to print to the Raspberry Pi which then turns around and prints to your regular printer via CUPS. I used my network laser printer for this, but there is no reason why you couldn’t use a hardwired printer (over USB) on the Pi itself. About a month ago, I succeeded. Last week, I put up a video demonstrating it, and today, I bring you the long-promised tutorial so that you can set it up yourself.
I’d like to thank Ryan Finnie for his research into setting up AirPrint on Linux and TJFontaine for his AirPrint Generation Python Script.
For the purpose of this tutorial, I used PuTTY to remotely SSH into my Raspberry Pi from my Windows 7 running Desktop PC.
To begin, let’s login to the pi which uses the username pi
and password raspberry
.
We now have to install a whole bunch of packages including CUPS and Avahi. Before we do this, we should update the package repositories as well as update all packages on the Raspberry Pi. To update the repositories, we type in the command sudo apt-get update
.
Naturally, this doesn’t quite work as expected, ending with an error requesting another package update. If you get this error just type in sudo apt-get update
again.
It seems the second time is the charm!
Now we need to upgrade the packages installed on the Pi using the new repository information we’ve just downloaded. To do this, we type in sudo apt-get upgrade
.
This will generate a list of packages to install and will then request approval before continuing. Just type in y
and press enter to let it continue.
This will take a few minutes as it downloads and installs many packages. Eventually you will be returned back to a bash prompt.
At this point, we have to begin to install all of the programs that the AirPrint functionality will rely on: namely CUPS to process print jobs and the Avahi Daemon to handle the AirPrint announcement. Run sudo apt-get install avahi-daemon avahi-discover libnss-mdns cups cups-pdf gutenprint pycups avahi python2
to begin this install.
Looks like some of those have been deprecated or had their names changed. We’ll have to install those ones again in a minute.
For some strange reason CUPS didn’t get installed, even though it was the list of programs to install in the last command. Run sudo apt-get install cups
to fix this.
Once again, it will need confirmation before continuing. As before, just type in y
and press enter to continue.
Once it finishes, you will again be returned to the bash prompt.
Time to install python-cups which allows python programs to print to the CUPS server. Run sudo apt-get install python-cups
to install.
Once you’ve returned to the bash prompt, run sudo apt-get install avahi-daemon
to install the avahi daemon (an mDNS server needed for AirPrint support).
For security purposes, the CUPS server requires configuration changes (managing printers, etc) to come from an authorized user. By default, it only considers users authorized if they are members of the lpadmin
group. To continue with the tutorial, we will have to add our user (in this case pi
) to the lpadmin
group. We do this with the following command: sudo usermod -aG lpadmin pi
(replace pi with your username).
Before continuing, lets start the cups service and make sure the default configuration is working: sudo /etc/init.d/cups start
.
Since we just tested CUPS’s default configuration, we might as well do the same to the Avahi-Daemon: sudo /etc/init.d/avahi-daemon
start.
If you get any errors during the previous two startup phases, it is likely that you didn’t install something properly. In that case, I recommend that you go through the steps from the beginning again and make sure that everything is okay! If you proceed through without any errors then it’s time to edit the CUPS config file to allow us to remotely administer it (and print to it without a user account on the local network – needed for AirPrint). Enter in sudo nano /etc/cups/cupsd.conf
.
The configuration file will load in the nano editor. It will look like this.
Use the down arrow until you come to the line that says Listen localhost:631
.
This tells CUPS to only listen to connections from the local machine. As we need to use it as a network print server, we need to comment that line out with a hashtag(#
). As we want to listen to all connections on Port 631, we need to add the line Port 631
immediately after the line we commented out.
We also need to tell CUPS to alias itself to any hostname as AirPrint communicates with CUPS with a different hostname than the machine-defined one. To do this we need to add the directive ServerAlias *
before the first <Location />
block.
To continue setting up remote administration, there are several places that we need to enter the line Allow @Local
after the line Order allow, deny
– however this does not apply to all instances of that line.
We now need to save the CUPS config file and exit the nano text editor. To do this hold down ctrl
and press x
. You will be prompted to save the changes. Make sure to type y
when it prompts you.
It will then ask you to confirm the file name to save to. Just press enter
when it prompts you.
Next, we need to restart CUPS to have the currently running version use the new settings. Run sudo /etc/init.d/cups restart
to restart the server.
It’s time to find out the Pi’s IP address to continue setting up printing via the web configuration tool. In my case, my Pi is assigned a static address by my DHCP server of 192.168.1.75
. To find out your Pi’s IP address, just run ifconfig
.
Once we have the IP address, we can open a browser to the CUPS configuration page located at ip_address:631
. More than likely you will see a security error as the Raspberry Pi is using a self-made SSL certificate (unless you have bought and installed one).
To continue on, click on Proceed anyway or your browser’s equivalent if you are sure you have entered in the correct IP address. You will then see this screen.
From there, go ahead and click the Administration tab at the top of the page. You will need to check the box that says Share Printers connected to this system
and then click the Change Settings
button.
CUPS will request password authentication, and since we added the user pi
to the lpadmin
group earlier, we can login with the username pi
and password raspberry
.
The CUPS server will write those changes to it’s configuration file and then reboot.
At this point, it is time to setup your printer with CUPS. In my case, I am using a Brother HL-2170w network laser printer and my screenshots will be tailored to that printer. Most other printers that are CUPS compatible (check http://www.openprinting.org/printers for compatibility) will operate the same way. If you are using a USB printer, now is the time to plug it in. Give it about a few seconds to get recognized by the Pi and then click the Add Printer
button to begin!
CUPS will begin looking for printers. Just wait till it comes to a list of discovered printers.
Eventually you will come to a page that looks like this:
Once you have chosen the correct printer and clicked continue – you will be brought to the settings page. Make sure to check the box regarding sharing or AirPrint may not work correctly.
You will then have to select the driver for your printer. In most cases, CUPS will have the driver already and all you need to do is select it – but with newer printers, you will need to get a ppd file from the OpenPrinting database and use that.
Then you need to set the default settings for the printer, including paper size and type. Make sure those match your printer so that everything prints out properly.
Once you are done, you should see the Printer Status page. In the Maintenance box, select Print Test Page and make sure that it prints out and looks okay.
If you get a proper test page, then you’ve successfully setup your CUPS server to print to your printer(s). All that’s left is setting up the AirPrint announcement via the Avahi Daemon. Thankfully, we no longer have to do this manually, as TJFontaine has created a python script that automatically talks to CUPS and sets it up for us! It’s time to go back to the Raspberry Pi terminal and create a new directory. Run sudo mkdir /opt/airprint
to create the directory airprint
under /opt/
.
We next need to move to that directory with the command cd /opt/airprint
.
Now we need to download the script with the following command: sudo wget -O airprint-generate.py --no-check-certificate https://raw.github.com/tjfontaine/airprint-generate/master/airprint-generate.py
Next, we need to change the script’s permissions so that we can execute it with the command sudo chmod 755 airprint-generate.py
.
It’s time to finally run the script and generate the Avahi service file(s). Use the command: sudo ./airprint-generate.py -d /etc/avahi/services
to directly place the generated files where Avahi wants them.
At this point everything should be working, but just to make sure, I like to do a full system reboot with the command sudo reboot. Once the system comes back up, your new AirPrint Server should be ready!
To print from iOS, simply go to any application that supports printing (like Mail or Safari) and click the print button.
Once you select your printer, and it queries it and will send the printjob! It may take a couple minutes to come out at the printer but hey, your iOS device is printing to your regular old printer through a Raspberry Pi! That’s pretty cool and functional right? And the absolute best part, since the Raspberry Pi uses such little power (I’ve heard it’s less than 10 watts), it is very cheap to keep running 24/7 to provide printing services!
UPDATE: If you are running iOS6, due to slight changes in the AirPrint definition, you will have to follow the instructions here, to make it work. Thanks to Marco for sharing them!
Superb post!
One to the things I want to do is to set the Pi up as a print server (although not with AirPrint) and this looks as a great resource to do that.
Cheers 🙂
Thanks! Yeah, you would be able to run through the whole setup until you've printed a test page and just stop there. If you're printing for Windows clients, there might be a bit more configuration to do manually on the client pointing it to the Raspberry Pi but it shouldn't be too difficult.
Great tutorial! Worked perfectly. I am printing from Windows 7 and stopped at the print test page as noted above. The only other thing to do was to add the printer to the windows system searching by name, which should look something like "https://192.168.1.68:631/printers/HP_DESKJET_845C"
My next challenge is to enable the printer to have a static IP, so when I reboot the PI I don't loose the printer.
Glad that it worked for you as well! That's exactly the way you need to add it to Windows. The steps should be similar for a Mac OS system.
In regards to the static IP, take a look at your router's setup page. You should have the option to create a static lease so that the DHCP server will always provide the same IP address to the Pi. Otherwise, you would have to setup a static IP on the Pi like this: http://www.linuxforums.org/forum/suse-linux/27880… making sure it's outside the DHCP range provided by your router.
Theres probably a obvious answer to this but how are you running the printer via the LAN port and connecting to your network at the same time? I can only think your using a wifi dongle or some form of a switch setup?
The printer is not connected directly to the Raspberry Pi's ethernet port. Both ethernet ports are connected to my preexisting LAN (connected to different switches that are also connected).
This is a great and informative post. However, when I get to the "Print Test Page" part nothing happens. It's flagging a warning to say "no profiles specified in ppd", although I don't know whether this may be a common message. The print queue then empties, as if to suggest it's been successful.
The printer I'm trying to setup is a Canon iP4000, which is already shared via my Airport Extreme Base Station (although I've also tried connecting direct and have experienced the same issue). I'm also running Arch and would be interested to know whether other Arch users have experienced a similar problem.
Thanks!
James,
I took a look at the OpenPrinting page for the Canon iP4000: http://www.openprinting.org/printer/Canon/Canon-i… and it says that it requires the gutenprint driver (which it failed to locate at the seventh step (above)). According to this link on the Raspberry Pi forums: http://www.raspberrypi.org/phpBB3/viewtopic.php?p…, the package needed is gimp-gutenprint. Try installing that package and printing again and see if that fixes your problem.
Thanks for the speedy reply Rohan!
Unfortunately it's still not working – I already had the gutenprint drivers installed, although did try reinstalling to see if that helped (the Pacman package is just gutenprint rather than gimp-gutenprint). CUPS currently reports to be using "Canon PIXMA iP4000 – CUPS+Gutenprint v5.2.8 (color, 2-sided printing)". I checked the Printers page and the status just shows "Idle – "Processing page 1…"".
James,
I'm a bit stumped on this one. This thread on Ubuntu Forums: http://ubuntuforums.org/showthread.php?t=38995 seems to say there is some manual configuring of the ppd file needed to get it to work. To confirm whether it's just an arch problem, if you have a second SD card, you could install Debian and see if that works better.
No luck with the Ubuntu thread but I'll give Debian a go and see how I get on…
Thanks again!
Good luck! I hope you get it working. It shouldn't be this difficult you know?
Pingback: Der Raspberry Pi Thread - Seite 14
Great Tutorial!
Hope I get it to work.
I made all steps, seems everything ok, cups running, avahi running, testpage printed, service file generated, but the printer is not found on the ipad.
If I make a search with "bonjour browser" on Windows I find a _ipp._tcp xxxxx @rasperrypi
So what can still be wrong?
any hints?
Have you checked and made sure that the iPad was connected to the same wifi network? When I was first testing with an iPhone, I made the mistake of trying to print connected to the 3g network instead of the wiring. I would also try disconnecting from the wifi network and reconnecting as sometimes the iPad fails to detect the connection. Good luck and let me know what happens.
Pingback: CUPS Success – at last!! | PackardNet
Hi there, & thank you for such a concise walkthrough.
I’ve two issues, the first being when I go to do a test print it just spits out a blank page. It sounds like it’s printing but when the paper comes out it’s blank?
The printer is a canon mx300 & after searching around I choose the ‘Canon PIXMA MP150 – CUPS+Gutenprint v5.2.8’ which is connected via USB.
I’ve also added it successfully to a mac 10.7 & again the test page goes fine but blank at the printer?
Also I noticed that from any of my iDevices I get to see two printers the CUPs printer Canon_mx300 & then the same again with airprint in front of the name airprint_Canon_mx300?
Thanks again..
Sounds like some sort of a driver conflict. What build of the Raspberry Pi Linux distributions are you using? Do you have the gutenprint driver installed?
Can I ask which build of Linux you used?
Fantastic project and want to re-create this at home with my pi 😀
I used the latest Debian build at the time (6-19-04-2012) and have tested with the older Debian build (6-13-04-2012). I have not tested with the current Rasbian build though I believe it should work just fine.
Hi,
Just followed your tutorial on Raspbian and everything goes fine until running the script where it says:
Traceback (most recent call last):
File "./airprint-generate.py", line 25, in <module>
import cups, os, optparse, re, urlparse
ImportError: No module named cups
cups is working fine and printing from other machines, just cant get the script to run. Any ideas?
You're missing the python-cups module. Try a sudo apt-get install python-cups to install the missing modules and then try running the script again.
Hi,
Installed ok and the script ran with no problems. Nothing is showing up in iPhone (running iOS6 Beta 3). Will try on an iOS5 device tomorrow.
Thanks for the help!
It might be related to the iOS version (maybe broken AirPrint?). I would be surprised if it was related to Raspbian.
Hi, all is working great on iOS5 so I'm guessing its an iOS6 problem that apple should work out. Thanks for all the help!
Thanks – great set of notes to work from, saved me a lot of research.
Please note as of the latest release I cut down the apt-get to:
apt-get install avahi-daemon avahi-discover libnss-mdns cups cups-pdf python-cups
python gets pulled in automatically.
Additionally it appears that cups shares via airprint with the above packages installed without the airprint scripts auto generated files.
I removed the generated files, after I got multiple entries on my ipad.
All in all great article – hopefully the above helps for minor corrections to the latest elements, and thanks again for spending the time to put this together.
Top marks
Thanks for the update David! Glad to hear that things are getting further simplified with later releases – my guess is that the later versions of CUPS integrate the avahi hookups on their own which is why you don't need the scripts anymore.
Thanks to Rohan and David(for amended note) this was a piece of pi to get AirPrint working on my Raspberrypi. A wee bit slow but hey printing from my iPad!
Very grateful to both 😉
Glad it worked Dave! At some point I will go through and amend the tutorial. I just haven't had a chance yet.
Does this only work when connected to a router (infrastructure) network? If I wanted to do this on the road, would I also have to make the pi an access point?
Yes that is correct. You do need to be connected to an infrastructure network. I'm not sure how it would work out with the pi acting as an access point but I would think it would be fine.
Any idea how to use this with Google Cloud print. I no longer have Apple devices, since Apple started to suck.
Yes! Take a look at using Armoo's Cloudprint python client – https://github.com/armooo/cloudprint It is very easy to implement and works well on Raspbian.
Hi! Thanks for the excellent guide. Unfortunately my RPi is unable to locate a few packages, such as avahi-daemon, gutenprint, python2, avahi and pycups. Can you give me a hint where to find them?
Thanks in advance for your help.
Hi Paul,
It sounds like you are running the new Raspbian builds which have renamed several of the packages. Trying just running an install of cups and see what it wants to bring in along with it – more than likely that will be enough to sort out the problem (as it should try to bring them in as most of them are dependencies).
Thanks for your tutorial, but I have a big problem with CUPS 1.5.3-1
I changed the cupsd.conf, restartet the Server and went to the Webinterface.
But as soon as I change something in the Administration-Panel and the Cups-Server restarts, i empties my cupsd.conf file! ITs completely empty after that 🙁
Any ideas?
I'm not sure what's going on. I haven't heard of it happeninjg to anyone else. Can you check that your SD card isn't corrupted causing data loss?
I have exactly the same problem.
Unfortunately, that's not something I have any experience with. I would recommend checking the CUPS bug reports because it's probable that such a problem would have been reported and patched.
I have exactly the same issue, as soon as I tick the box 'Share printers connected to this system' and click 'Change Settings' it appears CUPS does not write a new cupsd.conf, just a zero length file.
Having looked at the bug reports, for example, http://cups.org/str.php?L1976, it looks like it was closed in 2006. I'm not savvy enough with Raspbian to know how to apply the patch, so currently I can print a test page and not much else.
Do you know (a) if the patch has been applied, (b) how I do it as a novice or (c) what gets written and to which file, when you tick 'Share printers connected to this system'? Can it be manually changed and then CUPS restarted as a simpler work round?
Thanks otherwise for an excellent tutorial.
That bug Justyn mentions claims to be fixed in 1.3, I’d assume it is a red herring since it is so old. Something else may be happening. Check the docs for how to enable debugging or look through the cups logs. I think the following should show all logs.
cat /var/log/cups/*
You may need to use cupsctl at the command line to set up cups.
Isn’t cups 1.6.x the current release? I’d look into updating if possible.
I have a similar setup running, but I used ArchLinux since it boots quicker & is a smaller install. 1.6 adds it’s own mDNS service too, so you may see two advertised printers.
How can I install HPLIP (HP Linux Imaging and Printing – Print, Scan and Fax Drivers for Linux) on Raspian "wheezy"?
I saw this link (http://hplipopensource.com/hplip-web/install/manual/distros/debian.html) but it's confusing since it gives instructions on both Debian 5.0x and 6.0x. I don't want to break anything on my Pi since I'm not sure if it is compatible with Raspian "wheezy".
Note: The automagic printer-sharing has worked, and my Mac is connected to the local network properly, the Debian-based printer is visible in the list.
I have absolutely no idea as I don't use HP printers as all…
However, Debian Wheezy is version 7.0 of the Debian system. I would definitely try the Debian 6 instructions. Make sure that you make an image of the SD card first – in case it goes badly, you can always restore that.
I have done this but i didn't found any printers in printer list on my iphone
DId you verify that you were connected to the same WiFi network when you checked? On my first attempt, I hadn't actually setup the WiFi before trying.
Thanks very much for this tutorial, I was hoping to add air print server functionality to my Raspi which was running Raspmc (XBMC) I got all the way to the end and then rebooted but it seems I was asking to much (I am a complete novice) I had to add the command
Sudo usermod -a -G lpadmin pi
To get CUPS to recognise me as an admin
I will try again when I have a spare 4 hours or so on a clean install of Debian
That's in the original post though you might have missed that one line. Just to check, have you given it another shot yet?
Hi Rahon, this is great and worked well. I'm using my Raspberry Pi as to run raspbmc (XBMC port) and now this Airprint solution. One question .. How do I get cups to start up automatically? avahi-daemon does but not cupsd. Have to ssh in and run a sudo /etc/init.d/cups start. There's no /etc/rc.local!
Sorry…/etc/rc.conf!
Hi Steve,
That's not something that I've noticed before. The closest I can find is this thing on the Ubuntu Forums: http://ubuntuforums.org/showthread.php?t=1416651 which states to check your Loopback interface.
I'm having trouble getting two devices running the ios6 gold master to recognise my Raspberry Pi, though another iPad 3rd gen running Ios 5.1.1 isn't having this trouble. Do you know what could be wrong, Rohan?
Not sure – I don't actually have any ios devices with me right now to test with. My guess is that Apple changed something in the implementation of AirPrint and the CUPS/Avahi developers haven't made the changes server end yet.
Thanks Rohan! I'll try also checking my loopback interface for cups too.
Steve
No problem Steve. Let me know how it goes.
for iOS6 additions to the Avahi service definition see http://blog.mornati.net/2012/09/22/linux-airprint…
Really annoying this has stopped working with ios 6. Do you have any ideas on what may be the problem?
anon posted the solution: http://blog.mornati.net/2012/09/22/linux-airprint…
It seems that Apple slightly changed the service definition in iOS 6.
Why am I "anon" ? 😀
Marco (the one writing on blog.mornati.net) 😉
Hi Rohan, fantastic piece of work here. Mine works like a charm but not iOS 6 as per Steve's post. Have you heard anything from a dev point of view for the cups servers etc?
Martin
See what anon posted yesterday: http://blog.mornati.net/2012/09/22/linux-airprint…
Seems there was a definition change in iOS 6
I’m not sure if the airprint-generate.py script is needed.
Cups 1.4 included dns-sd…
http://www.cups.org/documentation.php/doc-1.4/wha…
It seems to be another mDNS service that gets automatically created after you enable printer sharing & setup a Printer.
Look at the advanced section of the Server settings (in the CUPS web admin). It should have an option for DNS-SD. It seems to create a more accurate service compared to the airprint-generate.py, e.g. it has the driver correctly listed, more printer settings are advertised.
I just did this on the latest 2012-09-18-wheezy-raspbian.img & the dns-sd printer service appears on my OS X & iOS devices.
I guess avahi may be left out of the build if CUPS is making its own mDNS server?
Any ideas what is going on? I’ll see if it stays stable without the airprint-generate.py service.
You're right, it should be able to be left out. I think that's a recent addition to CUPS as it wasn't there when I did the original guide.
I have avahi running too (to announce AFP sharing for a TimeMachine server), which may be unnecessary but it doesn’t seem to conflict.
Here’s where I found how to set that up … it turns the Pi into a Time Capsule 🙂
http://www.andadapt.com/2012/09/06/raspberry-pi-r…
How is the file read/write speeds doing that with the Pi? I would think with USB and ethernet sharing a bus, it would not be worth it in the long run.
It seems to run upto 7MB/sec. Fairly average 100BaseT speeds. It is slower with many small files compared to large changes. Just over 300GB copied across the network in about 2 days IIRC.
An Apple Time Capsule is quicker with Gigabit ethernet, but they use 10 times the electricity & cost around twice the price. I had a spare disk around & the USB case, so really it was around 1/6th the price of a Time Capsule 🙂
One side benefit is that the client machine no longer gets ‘Time Machine lag’, where the OS slows down due to the intensive File IO writing to a Firewire disk. I think I may use it for backing up a laptop, which wouldn’t be able to benefit from Gigabit speeds anyway.
That's not bad for something that is sharing the bus. Makes sense for a small operation like that – but I would definitely not replace a full file server with a Raspberry Pi.
Ehehe I was joking 😀
But really cool guide… I think (when finally I'll receive my rasperry) I'll switch my linux printer server to rasperry thanks to you 😀
Marco
Cool. I can tell you that it's a lot more power efficient than keeping a full linux server running especially for printing.
Yes that the reason I want to buy it. But actually I've an Atom PC this is not take much power, but it's surelly more than a Raspberry PI 😉 (especially because I've a SATA drive inside) 😉
Marco
Most definitely, especially considering that the Pi and it's USB power supply will pull less than 6 watts of power when running.
Everything worked perfectly but I found an error and had one problem at the end.
Don't copy the exact text in this article for this command: sudo usermod – aG lpadmin pi
There is an extra space between the "-" and "aG" which makes the command fail.
Also, my printer set up correctly, but Airprint in iOS 6 does not find the printer. I'm not sure why since the test page printed correctly.
I've removed the extra space now. As for iOS6, there's been a link floating about in the comments for a little while. http://blog.mornati.net/2012/09/22/linux-airprint…
Works Brilliantly, thank you very much ! On IOS 5 for a more elderly ipad V1 and it couldn't be easier.
I'm glad to hear it!
Another note, when rebooting my pi – airprint stopped working. I noted that the avahi-daemon wouldn't start after a reboot – I have to remove the /var/run/avahi-daemon/disabled-for-unicast-local file and then manually start avahi-daemon. Then it works. Any tips on how to reboot without having to manually remove that file each time?
Also – now that my iOS 6 devices are running, my iPad (iOS 5) can't print. I can't update a first gen iPad to iOS 6. I tried creating a second printer in CUPS and not edit the .service file for it, but that doesn't seem to work. Any tips for printing from both iOS5 and iOS6?
I'm not sure. I don't actually have any iOS devices with me here to test with but my guess would be using the existing setup for the iOS6 devices would work and use the airprint generate script (I linked to it in the post) to connect the iOS5 devices.
It seems to be related to the /usr/share/cups/mime/apple.types file. If it doesn't exist, I can print from iOS 5 but not iOS 6. If it exists, I can print from 6 but not 5. From the notes, that file is supposed to contain "image/urf urf (0,UNIRAST)" – I think I read someplace that iOS 5 would use a pdf format for airprint instead of urf as it does for iOS 6 – so I'm guessing that there needs to be a reference to image/pdf in the apple.types file but not having any luck. Any ideas?
I've been working on this yesterday and noticed similar findings. I've been trying many of the fixes outlined on this thread at the Ubuntu Forums: http://ubuntuforums.org/showthread.php?t=2060594&… but was not able to get it to work for IOS6. In the end the IOS5 devices see the printer twice (once from CUPS and once from Avahi)…. Hopefully someone will figure out the fix and bundle it into CUPS on the Pi soon.
This is great. I did this pretty much step for step and my 1st Gen iPad was printing right away. I will note that depending on which driver you select it can really make a difference in speed – for instance a recommended PS driver for an HP took 6 min to print a test page, using the CUPS+Gutenprint driver took less then 1 min. I just wanted to mention about the iOS 6 update above – we also have a couple of iPhones running iOS 6. For newbies, like myself, the update says to modify the .service file and create two other files – but it wasn't clear where the .service file resides – I found mine in the /etc/avahi/services directory – I believe there will be a printername.service file for each printer installed in CUPS. Then once I created the two files like it says, it worked like a charm.
My guess is that the open source CUPS drivers are much more efficient in their processing times. Thanks for sharing where to find the .service files – I'm sure that will help other people.
Thanks for the guide, i have CUPS up and running withy the web interface connected to my printer. I have printed a testpage, works 🙂 i can see a airprint printer with the same name, i can print from IOS6 i says printing page .. of .. but then nothing happens, nothing in the log on cups, nothing on the printer, what could be wrong ?
I'm honestly not sure. I don't have any IOS 6 devices to test with and I haven't seen that with IOS 5 at all. Can you try recreating the service files for avahi daemon?
tried that, but still nothings happens, is there a log a can look into, in order to debug the problem eg. is there a avahi log to se if the service has been hit by the ios6 device and also if it has any problems contacting the CUPS server
According to this page: http://www.unix.com/unix-dummies-questions-answer… avahi stores its log in /var/log/messages
As far as checking the CUPS server, you can open the CUPS web interface and see if your job from IOS 6 shows up in the jobs list. That will tell you whether the problem is on Avahi's end or on CUPS's end.
Hi,
Thank you for this tutorial, is working good for me little slow (load aver 3.0 on rasp) but it's ok !
(printer canon mx420, raspberry pi – rasbian with cups 1.5.3)
Glad to hear it! Thanks for reporting in!
when going to my //myipadres:631/admin and then to admnistrator it says formbidden…
It sounds like you forgot to set the permissions for the admin section. Go through and make sure you added the line @Local everywhere indicated in the config file (specifically the one with the /admin link).
Unfortunately when i use this command: ./airprint-generate.py -d /etc/avahi/services
i get this error:
Traceback (most recent call last):
File "./airprint-generate.py", line 25, in <module>
import cups, os, optparse, re, urlparse
ImportError: No module named cups
root@raspberrypi:/opt/airprint# python-cups
bash: python-cups: command not found
I did everything like you wrote but i couldn't understand what's happened!!!
Please help me!!! thanks 😉
Sounds like you forgot to install the python-cups package. Run a "sudo apt-get install python-cups" and you should then be able to run the airprint generation script.
Right now i can print, but i don't know why after 5 minute of printing sheet suddenly it doesn't work!! Also with iOS 6 i could print, but maybe it's some IP trouble i don't know!!!
And it says also that i couldn't connect to the printer..
And finally this is the error log i hope that i could help you:
E [30/Dec/2012:09:48:03 +0000] Unable to open listen socket for address [v1.::1]:631 – Address family not supported by protocol.
E [30/Dec/2012:09:48:51 +0000] Avahi client failed, closing client to allow a clean restart
E [30/Dec/2012:09:49:57 +0000] Unable to open listen socket for address [v1.::1]:631 – Address family not supported by protocol.
E [30/Dec/2012:10:03:15 +0000] Unable to open listen socket for address [v1.::]:631 – Address family not supported by protocol.
E [30/Dec/2012:10:04:28 +0000] Unable to open listen socket for address [v1.::]:631 – Address family not supported by protocol.
E [30/Dec/2012:10:05:10 +0000] [cups-deviced] PID 13402 (snmp) stopped with status 1!
E [30/Dec/2012:11:24:00 +0000] [cups-deviced] PID 13462 (snmp) stopped with status 1!
E [30/Dec/2012:11:25:30 +0000] [cups-deviced] PID 13484 (snmp) stopped with status 1!
W [30/Dec/2012:11:26:39 +0000] failed to CreateProfile: org.freedesktop.DBus.Error.NoReply:Message did not receive a reply (timeout by message bus)
W [30/Dec/2012:11:26:39 +0000] failed to CreateProfile: org.freedesktop.DBus.Error.NoReply:Message did not receive a reply (timeout by message bus)
W [30/Dec/2012:11:26:40 +0000] failed to CreateDevice: org.freedesktop.DBus.Error.NoReply:Message did not receive a reply (timeout by message bus)
W [30/Dec/2012:11:26:52 +0000] failed to CreateProfile: org.freedesktop.ColorManager.AlreadyExists:profile id 'Stampante-Gray..' already exists
W [30/Dec/2012:11:26:52 +0000] failed to CreateProfile: org.freedesktop.ColorManager.AlreadyExists:profile id 'Stampante-RGB..' already exists
W [30/Dec/2012:11:26:52 +0000] failed to CreateDevice: org.freedesktop.ColorManager.AlreadyExists:device id 'cups-Stampante' already exists
W [30/Dec/2012:11:26:52 +0000] failed to CreateProfile: org.freedesktop.ColorManager.AlreadyExists:profile id 'Stampante-Gray..' already exists
W [30/Dec/2012:11:26:52 +0000] failed to CreateProfile: org.freedesktop.ColorManager.AlreadyExists:profile id 'Stampante-RGB..' already exists
W [30/Dec/2012:11:26:52 +0000] failed to CreateDevice: org.freedesktop.ColorManager.AlreadyExists:device id 'cups-Stampante' already exists
E [30/Dec/2012:11:42:27 +0000] [cups-deviced] PID 13632 (snmp) stopped with status 1!
E [30/Dec/2012:11:48:47 +0000] Missing printer-uri, job-uri, or ppd-name attribute
E [30/Dec/2012:11:48:47 +0000] Returning IPP client-error-bad-request for windows-ext (no URI) from 192.168.1.7
E [30/Dec/2012:15:39:43 +0000] Avahi client failed, closing client to allow a clean restart
E [30/Dec/2012:15:40:24 +0000] Unable to open listen socket for address [v1.::]:631 – Address family not supported by protocol.
W [30/Dec/2012:15:47:17 +0000] failed to CreateProfile: org.freedesktop.ColorManager.AlreadyExists:profile id 'Stampante-Gray..' already exists
W [30/Dec/2012:15:47:17 +0000] failed to CreateProfile: org.freedesktop.ColorManager.AlreadyExists:profile id 'Stampante-RGB..' already exists
W [30/Dec/2012:15:47:17 +0000] failed to CreateDevice: org.freedesktop.ColorManager.AlreadyExists:device id 'cups-Stampante' already exists
E [30/Dec/2012:15:47:17 +0000] Unable to open listen socket for address [v1.::]:631 – Address family not supported by protocol.
E [30/Dec/2012:15:47:17 +0000] Failed to update TXT record for Stampante @ raspberrypi: -2
W [30/Dec/2012:15:47:18 +0000] failed to CreateProfile: org.freedesktop.ColorManager.AlreadyExists:profile id 'PDF-Gray..' already exists
W [30/Dec/2012:15:47:18 +0000] failed to CreateProfile: org.freedesktop.ColorManager.AlreadyExists:profile id 'PDF-RGB..' already exists
W [30/Dec/2012:15:47:18 +0000] failed to CreateDevice: org.freedesktop.ColorManager.AlreadyExists:device id 'cups-PDF' already exists
E [30/Dec/2012:18:42:14 +0000] Unable to open listen socket for address [v1.::]:631 – Address family not supported by protocol.
E [30/Dec/2012:18:46:03 +0000] Avahi client failed, closing client to allow a clean restart
E [30/Dec/2012:18:46:43 +0000] Unable to open listen socket for address [v1.::]:631 – Address family not supported by protocol.
E [30/Dec/2012:18:52:47 +0000] Unable to open listen socket for address [v1.::]:631 – Address family not supported by protocol.
E [30/Dec/2012:18:55:25 +0000] Avahi client failed, closing client to allow a clean restart
E [30/Dec/2012:18:56:04 +0000] Unable to open listen socket for address [v1.::]:631 – Address family not supported by protocol.
E [30/Dec/2012:19:18:58 +0000] SSL shutdown failed: Error in the push function.
E [30/Dec/2012:19:18:58 +0000] SSL shutdown failed: Error in the push function.
E [30/Dec/2012:19:19:00 +0000] SSL shutdown failed: Error in the push function.
Unfortunately, I have no idea what that means. I would recommend posting a question on Linux Forums or the Unix StackExchange board. Hopefully someone there can shed some light on what the error message means. Alternatively, I would try a full restart of the Pi as it is possible that after updating some config files, you did not restart all of the services with the possibility of an incorrect configuration running in RAM.
Pingback: uweziegenhagen.de » Blog Archive » Printing from iOS via Raspberry Pi
Pingback: Raspberry Pi als Server für AirPrint by
thanx ! really rock !
Pingback: Lynsay's Little World » Wireless Printing/AirPrint Server via the Raspberry Pi
Pingback: Raspberry Pi ทำ AirPrint Server | Raspberry Pi Thailand
Hi!
I've setup and everything is working fine! But there's one problem, if I print photos from my iPad/iPhone, the images are shrinked on the paper. If I print via my Mac, its all fine. And there's no printing options on iOS. Any suggestions?
I have no idea though I have noticed the same problem myself… I'm assuming it's a limitation that Apple built into the Airprint system.
Hello Everyone,
I am new to this in fact never done command line nor ever tried linux until raspberry pi. i love it and am trying to learn as fast as i can. i followed the tutorial above but got stuck and would like to ask for your help.
1, when i put in the usermod command to change the the user to pi it say its not a valid command.
2, the ip_ my ip address :631 is also coming up invalid ?
am stuck here can anyone pls advice on what i have missed or done wrong.
thank you
Please make sure that you've correctly typed in the command. It should be sudo usermod -aG lpadmin pi
Hey, this is a very very good tutorial thank you very much 🙂
But i have 1 problem, everything worked well till i wanted to run the airprint script, it gave me the following problem back:
pi@raspberrypi /opt/airprint $ sudo ./airprint-generate.py -d /etc/avahi/services
Traceback (most recent call last):
File "./airprint-generate.py", line 25, in <module>
import cups, os, optparse, re, urlparse
ImportError: No module named cups
Sounds like you missed pycups.
Do a sudo install pycups before running that script and you should be fine.
Thank you very much, this is a fantastic tutorial and has allowed me to print from my ipad to my two non AirPrint epson printers which I thought would never be possible but knew it surely would be. It has also given a definite purpose to my raspberry pi alongside it running noip.
I'm glad you found it useful.
The section with Avahi/AirPrint scripts is no longer needed with current CUPS version. Add and share printer with CUPS and you are done 😉
Good to know that the process has been simplified.
LMAO, I mentioned Avahi wasn't required last September in your comments 🙂
P.S.
You have a 6.6Mb background image on this site – it makes your pages load really sslllooowwwlllyyy. I'm glad i'm not on cellular data, that lizard is expensive… https://rohankapoor.com/wp-content/uploads/2013/01… You may want to run it through http://imageoptim.com (I'm assuming your on a Mac because of Airprint). Also try the network section of the 'inspector' in webkit browsers.
I'm actually not on a Mac at all… do appreciate the heads up as to the size though. I'll have Photoshop compress for web and swap it out.
Thanks
That’s better but 1.8MB is still big for a file that only shows around the edges of a page IMO. Photoshop’s low quality at 2000px wide will squash it down to about 1/10 of that size. The quality shouldn’t be too distracting considering it’s not in the main content.
Is there a good reason for it being so big? The overall page load total is also around 4.5MB too.
Anyway, I’ll stay on topic in future, cheers for the guide.
Thanks for the feedback and the suggestions. I'll take a look and see what I can do to shrink the overall page load size.
Great tutorial – up and running in no time. Like that you explain things too. Thanks
This article is very precise but I am on the point with unknown issue. I have my printer (EPSON R800) connected to Apple Time Capsule. Printer was detected and recognized, added, configured as: dnssd://R800._pdl-datastream._tcp.local/ but Test Page from Maintenance box on generates error: The printer is not responding.
Any idea what is wrong?
Best Regards,
I have no idea. The whole point with this article is to use the Raspberry Pi as the print server, I have no idea what could go wrong if you use an intermediary (like the Time Capsule).
Do I understand correctly that the only reason why it is server not client is tag-option "share printer"? In other words – how to print on Time Capsule/USB connected printer from Pi?
Thank you, really easy to follow. I learned a lot and managed to get the whole thing working perfectly.
My next job now is to set up Cloud Printing services so I can send stuff to my home printer whilst I'm at work.
Thank you so much Rohan, your walk-through worked first time for me and now we are able to print from our 2nd gen iPad running iOS 6.0.1
Thanks for your excellent tutorial. It would be great if you could follow up with the procedures for installing the CloudPrint server software. The site you refer to is a bit cryptic for a novice. Is this possible
I’ll definitely try to make a tutorial for this at some point. I do know that for a while though it was not actually working.
Many thanks…I would appreciate that…. I have a rather clunky work araound which involves keeping Chromium running all the time.
Pingback: Meine iOS 7-Wünsche