CUPS + AirPrint on Raspberry PI

Install CUPS and Enable Remote Access

apt-get install cups

 

Add Pi user to lpadmin group

usermod -aG lpadmin pi

 

Enable Remote Access

/etc/cups/cupsd.conf

Comment out Listen localhost:631 and add Port 631

then Allow access

/etc/cups/cupsd.conf

 

# Only listen for connections from the local machine
# Listen localhost:631
Port 631

 

< Location / >
# Restrict access to the server...
Order allow,deny
Allow @local
< /Location >

< Location /admin >
# Restrict access to the admin pages...
Order allow,deny
Allow @local
< /Location >

< Location /admin/conf >
AuthType Default
Require user @SYSTEM

# Restrict access to the configuration files...
Order allow,deny
Allow @local
< /Location >

 

Restart CUPS

/etc/init.d/cups restart

 

Now you are able to access remotely x.x.x.x:631 and add the printer

 

Install AirPrint

apt-get install avahi-discover cups cups-pdf python-cups

apt-get install hplip

 

Make your old printer AirPrint capable

 
/etc/init.d/avahi-daemon start mkdir /opt/airprint cd /opt/airprint wget -O airprint-generate.py --no-check-certificate https://raw.github.com/tjfontaine/airprint-generate/master/airprint-generate.py chmod +x airprint-generate.py ./airprint-generate.py -d /etc/avahi/services /etc/init.d/avahi-daemon restart ls /etc/avahi/services/

Add those files with this content

/usr/share/cups/mime/local.convs

/usr/share/cups/mime/local.convs
image/urf application/vnd.cups-postscript 66 pdftops

 

/usr/share/cups/mime/apple.types

/usr/share/cups/mime/apple.types
image/urf urf (0,UNIRAST)

 

/usr/share/cups/mime/apple.convs

/usr/share/cups/mime/apple.convs
image/urf application/pdf 100 pdftoraster

 

Open port 631

iptables -A INPUT -i eth0 -p tcp -m tcp –dport 631 -j ACCEPT

iptables -A INPUT -i eth0 -p udp -m udp –dport 631 -j ACCEPT

 

Disable power saving (optional)

/etc/modprobe.d/8192cu.conf
 
/etc/modprobe.d/8192cu.conf
# Disable power saving options 8192cu rtw_power_mgnt=0 rtw_enusbss=1 rtw_ips_mode=1
 

Connect from windows

http://server_ip:631/printers/printer_name

 

 

7 Comments so far:

  1. Congratulations.
    I was searching about 3 weeks for a solution with my canon-ts5050 printer. I have contacted canon and they returned their printer are only working in win and mac. But your way was right to print in raspbian. I am happy. Thank you.

    • glad to help,.. it was all about my 25 years old HP laser jet,.. it works much better then printers you can buy these days,..

  2. So I was able to follow it halfway… I came to the section the files in the /mime/ folder, but I am not able to find any of those files. Do I need to create those files?

  3. so far this was the only method that made my airprint to work with raspberry but many times doesnt show to print or takes some time to find the printer. Any idea what could be the issue?

  4. It is some network conflict most likely. Never google for it, so I have no proof, but it seems to me that some routers has problem with air print protocol. I had similar situation where I needed to reconnect to wifi in order to see printer. Then I changed my internet provider, got new router, and never have that issue again.

Leave a Reply

Your email address will not be published. Required fields are marked *

Posted by: lesorsier on

Tags: ,