Welcome! Log In Create A New Profile

Advanced

Re: Howto: Use your Dockstar/GoFlex to enable iOS AirPrint with any printer supported by CUPS

Posted by Vlad 
Here I'd like to explain how you can use your GoFlex/Dockstar to enable AirPrint on any printer that is supported by CUPS. The idea behind is that avahi sends announcements which make iOS think that the printer is AirPrint compatible. Of course this works only for iOS versions that support AirPrint.

I'm not the author of the original howto which first appeared on the Arch Linux ARM wiki
http://archlinuxarm.org/support/guides/applications/cups-apple-airprint
All I did was to "port" the howto which was meant for Arch to Debian Squeeze and make some small corrections. Kudos to the Arch Linux ARM project for the howto and to Timothy J Fontaine for his Python code that creates correct avahi announcements.

First we need to install some packages.
apt-get install cups-pdf avahi-daemon python-cups cups-driver-gutenprint
apt-get install foomatic-db foomatic-db-engine foomatic-filters foomatic-filters-ppds
If you have a HP printer you should also install hplip
apt-get install hplip
Now we add a user "printerguy" who is allowed to configurre CUPS
adduser printerguy --no-create-home --shell /bin/false --ingroup lpadmin
Then we edit CUPS' config file
nano /etc/cups/cupsd.conf
after the line "Listen /var/run/cups/cups.sock" paste this
Listen IP-OF-YOUR-DEVICE:631
PreserveJobHistory		No 
FileDevice Yes 
ServerAlias *
also replace
# Restrict access to the server...
<Location />
  Order allow,deny
</Location>

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

# Restrict access to configuration files...
<Location /admin/conf>
  AuthType Default
  Require user @SYSTEM
  Order allow,deny
</Location>
by
# Restrict access to the server...
<Location />
Order allow,deny
allow @LOCAL
</Location>

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

# Restrict access to configuration files...
<Location /admin/conf>
AuthType Basic
Require user @SYSTEM
Order allow,deny
allow @LOCAL
</Location>
and finally restart CUPS
/etc/init.d/cups restart
Open the local CUPS page in a web browser:
http://IP-OF-YOUR-DEVICE:631
If you have a network printer (LAN,WiFi, JetDirect), turn it on. If your printer is USB only, connect it to your GoFlex/Dockstar.
Go to "Administration" and click on "Add Printer". When asked for credentials use
login: printerguy
password: printerguy's password
CUPS will start looking for your printer. Select it, click next, allow sharing, and click next again. On the next page you must select the "driver". Usually there are several possibilities. If unsure, go to
http://www.openprinting.org
and see which PPD works best with you printer. For HP printers always go with hpcups. Finish the installation. Now go to "Printer" in the bottom right of the page, press the "Maintenance" drop-down menu and select "Print Test Page" to make sure it works properly. With the aid of Timothy J Fontaine's python script, we can generate avahi announcements that will make iOS think that our printer is AirPrint capable. All you need to do is
/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/
you should see something like "AirPrint-Name-of-your-printer". Just in case I attached the script to this post.

On the iOS side there's nothing you really need to configure. Just go to an app that supports printing, for example mail or goodreader and select print. Everything works out of the box.

I've been testing this with my iPad 2 (iOS 4.3.3) and my two HP printers (Laserjet 1015 and Officejet 6500) for about a month. Laserjet 1015 is connected to my router via an old JetDirect print server and Officejet 6500 uses WiFi. Both printers are not ePrint or AirPrint capable but together with my GoFlex Net everything works like a charm.



Edited 2 time(s). Last edit at 10/15/2011 04:29PM by Vlad.
Attachments:
open | download - airprint-generate.py (9.6 KB)
Hi,

nice how-to. Except from some lines, i treid to print from my ipad, but no way. I tried to had the lines you have, and still no way to print... :(

In fact the printer is seen, the job goes to the queue, but it is stopped as soon as it arrives. My cups server works good with all my other stuffs (windows only...). No way to print from my ipad :(

Printer : Canon MP150
Cups server : last version on the debian squeeze on THE dockstar ;)
Re: Howto: Use your Dockstar/GoFlex to enable iOS AirPrint with any printer supported by CUPS
November 11, 2011 12:17PM
Frankly speaking I have no idea. I used this howto to setup my both HP printers as described above and everything works flawlessly on my iPad 2 with iOS 5.0.1. I haven't experienced a single error so far.
hmmmm... I'll admit that I saw the title of your post, Vlad, and just skimmed the contents... saw """ CUPS """ and wondered if something was hackable for p910nd, which I use....

I'll have to google it... anyway thanks for the writeup, the references, and the idea-passed-on...

=====================================================
Hi there,

i did your described changes and was able to print on my canon ip5000 over iPad+iPhone like a charm. But now i updated to debian wheezy and it does not work anymore. Im able to install the printer with cups web interface, but when i print it seems that the assigned task does not make it to the printer because it does nothing. But in cups i see the print-job so it seems that it just not arrives at the printer. Any ideas? Help would be really appreciated, I'm actually new to linux. Regards
Re: Howto: Use your Dockstar/GoFlex to enable iOS AirPrint with any printer supported by CUPS
February 10, 2012 05:04PM
Did you check if the cups itself works properly? Can your printer print a test page from CUPS webinterface?
Hi Vlad,

no the test page is not printing- i see it in the jobs list on the cups interface but the printer is not printing; if connected directly the printer works of course
Re: Howto: Use your Dockstar/GoFlex to enable iOS AirPrint with any printer supported by CUPS
February 12, 2012 11:47AM
I'm not a CUPS expert but if the printer is not working properly with CUPS, it's pretty obvious that AirPrint won't work too. I never had any Canon printers so I can hardly give you an advice how to make it working. It's strange but IP5000 is not even listed in the OpenPrinting Database. May be someone who has more experience with the IP series can help you.
Hey all,

I have tried this exact setup on 2 different ubuntus, and my printers are not discoverable from either iPad or iPhone (iOS 5.1), ending with the dreadful "No Airprint Printers Found".
Bonjour browser however lists all my printers correctly, and I can print test pages from my CUPS configuration to all three of the printers we have installed here...

Any idea of what I should do next?
Thanks
Julien
Vlad, very nice... I think I've finally decided to go w/ CUPS instead of p910nd (which is excellent, but doesn't support AirPrint directly - but read through to the end to see how I reincorporated p910nd).


For this to work for me (function and preference, both), made a few minor changes:

0. I had to back down to Squeeze, since CUPS is broken in Wheezy ATM (8/24/12)


1. I added in python-lxml, since, as I understand it, it makes the .service file human-readable.
apt-get install python-lxml
[if I err on my understanding of this, please advise... thanks]



2. My /etc/cups/cupsd.conf file needed some tweaks for it to work properly for me - IIRC these were related to access/permissions to the cups admin pages. Once I changed those, I no longer saw the "Forbidden" messages on my web browser.

**A weird symptom that I was seeing was that no .service file was generated. Once I fixed the sharing/access arrangements, the .service file was generated.



3. I'm suspecting that some characters cannot be used in a .service file - I had to simplify & shorten the name of my printer in the service file for it to work.

A nice tool for this was the Avahi Browser that is available in Ubuntu (of course, for most *nix systems, such avahi/zeroconf/bonjour browsers are commonly available).



4. After a bit of thought... I went back to p910nd Avahi doesn't seem to allow for two different .service files for a single IP:port. Since the automatically generated file (airprint-generate.py's output) is keyed for AirPrint from iOS devices (which require it to be processed as a pdf/ghostscript style), the same service advertisement doesn't fully work for non-iOS devices. My Mac tried to autoselect the postscript driver for it... that was a no-no. No-go.

The workaround for this was already suggested by Povey, or one of the original authors that wrote it up: instead of setting up CUPS's target to be the attached USB printer,
A. set the USB printer up w/ p910nd (confirm it is working as a JetDirect printer),
B. point CUPS toward the printer via socket://127.0.0.1:9100 as a AppSocket/HPJetDirect printer.

In this way,
-all print jobs from laptops and full-fledged computers print straight through via p910nd, but
-all print jobs from iOS devices/AirPrint go instead first to CUPS to be processed, and then from CUPS to p910nd.

This makes better sense to me, and eliminates any unnecessary processor load for the Dockstar/Pogoplug/Kirkwoodbox. [CUPS creates a significant amount of processor load when it is processing a job for iOS. On the other hand, p910nd uses virtually no processor cycles (comparatively), since it is simply a pass-through spooler.]

Below are my avahi service files, for reference.

AirPrint-HP_C4480.service for iOS Devices/AirPrint only
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
  <name replace-wildcards="yes">AirPrint/iOS HP_C4480 @ %h</name>
  <service>
    <type>_ipp._tcp</type>
    <subtype>_universal._sub._ipp._tcp</subtype>
    <port>631</port>
    <txt-record>txtvers=1</txt-record>
    <txt-record>qtotal=1</txt-record>
    <txt-record>Transparent=T</txt-record>
    <txt-record>URF=none</txt-record>
    <txt-record>rp=printers/HP_C4480</txt-record>
    <txt-record>note=HP Photosmart C4480</txt-record>
    <txt-record>product=(GPL Ghostscript)</txt-record>
    <txt-record>printer-state=3</txt-record>
    <txt-record>printer-type=0x900c</txt-record>
    <txt-record>pdl=application/octet-stream,application/pdf,application/postscript,application/vnd.cups-raster,image/gif,image/jpeg,image/png,image/tiff,text/html,text/plain,application/openofficeps,application/vnd.cups-banner,application/vnd.cups-pdf</txt-record>
  </service>
</service-group>



HP_C4480.service - for non-iOS/AirPrint Computers (Laptops, Desktops, etc.)
<service-group>
<name replace-wildcards="yes">HP PhotoSmart C4480 @ %h</name>
<service protocol="any">
#<host-name></host-name>
<type>_pdl-datastream._tcp</type>
<port>9100</port>
<txt-record>product=(HP Photosmart C4400 series)</txt-record>
</service>
</service-group>



5. Since you have avahi installed, you might as well make use of it - make it easier to administer CUPS. Advertise the CUPS admin page of your printer locally via Bonjour... (yes, think about security on this...YMMV)

Here is my CUPS-admin.service file:
<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name replace-wildcards="yes">CUPS Admin Webif @ %h</name>
<service>
<type>_http._tcp</type>
<port>631</port>
</service>
</service-group>




Again, a tip of the hat and thanx @ Vlad!
==================================
NOTE: This worked fine for me in Squeeze (stable) but not in Wheezy (testing). ATM, CUPS in Wheezy seems to be broken due to a dependency problem. Aug 24 2012

=====================================================



Edited 6 time(s). Last edit at 08/25/2012 12:28PM by davygravy.
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: