Universal Mobile Print Server
Universal Mobile Print Server
Universal Mobile Print Server
If youre like me, your house is full of mobile devices: my kids have iPads, my wife and I have Android
tablets and phones. We all need to print at some point. It may be that your existing printer works with
some devices but not others. Maybe you have several older printers, including a USB printer. Maybe you
want to print MS Office documents from your phone without using the Cloud.
The one simple answer to this scenario is the Raspberry Pi; a dirt-cheap (USD$35) computer on a chip
that costs less than a replacement ink-jet cartridge and can be made to connect to just about any mobile
device and almost any printer. All you need is 2 hours and a desire to learn about Linux.
Now install CUPS and AVAHI. CUPS is the Common UNIX Printing System an open-source printing
solution. AVAHI is an open source Bonjour or ZeroConf package that is used for network discovery.
sudo apt-get install avahi-daemon cups cups-pdf
Now make the pi userid capable of administering the CUPS config:
sudo usermod a G lpadmin pi
Next you need to tweak the CUPS config file:
sudo nano /etc/cups/cupsd.conf
You are now using a simple notepad style editor to make the following changes to the config file. (NOOB
Hint: Use the cursor-arrow keys to navigate.)
-
On the first page, at about line 17: change Listen localhost:631 to Listen 0.0.0.0:631.
Scroll down until you reach the Location and Location /admin sections. Insert two lines with
the text Allow @local as shown in Figure 2
The ifconfig shows the address of your Pi on your network. Now open a browser session on your Pi or
from any computer on your local network and type the following where the xs are your Pis IP address:
https://xxx.xxx.xxx.xxx:631
And you should see the following
You may see a warning about the web sites certificate. You can ignore this as you should trust this site,
after all you just installed it. If you are prompted for a userid/password then use your pi userid and
password. At this point be sure your printer is powered on.
Choose the Administration tab and then the Find New Printers button. If you are lucky you will see
your printer(s) listed among the Discovered Printers. (If you do not see your printer, see the Manual
Print Config section below.) If the printer is shown then select it and press continue. Choose the default
Connection and press Continue. Choose Share This Printer and continue. (Figure 5)
Once complete, return to Administration Tab, then choose Manage Printers. Select your printer and
print a test page. (Figure 7)
If the test page does not print you have likely chosen the wrong driver model. Do a Google search of
your make/model to see if anyone else has configured it using CUPS. Then choose the Administration
pull-down menu this time (Figure 7) for that printer and select Modify to change it as needed
If you have a laser printer that you know understands HP PCL or Postscript (the two most common
varieties) and you know its IP address then manual config should be easy. Choose the AppSocket/HP Jet
Direct connection option under the Add Printer page (Figure 8):
Type your printers IP Address in the connection after the socket prefix (Figure 9):
Choose Generic for the Make if you know that your printer is compatible with HP PCL or Postscript.
(Figure 10)
Figure 10 - Generic Make and Model for typical PCL or Postscript Laser Printer
Once the printer is added, print a test page as described above. (Figure 7)
Mobile Printing
Once you get one or more printers working on your Pi, something magical happens: CUPS publishes
these printers and then the Avahi software advertises them on your local network.
You should now be able to print from your iOS devices. Try going through printer discovery by
attempting to print a web page from the Safari browser. After a few seconds delay, your printers should
show up as printername @ raspberrypi.
To print from Android, install the app Lets Print Droid on your Android devices. If you have the KitKat OS
or better then you can also install Lets Print Framework.
On your Android devices, run the Lets Print Droid application, choose menu->New Printer and select
the Scan option. The scan should find each of your printers and configure them with a name like
printername @ raspberrypi. After the scan completes you can print a test page by hitting menu>Test Print from the scan window.
We start by installing LibreOffice for the Pi. Open the Pi Desktop agin and double-click on the Pi Store
icon.
Do a search for libreoffice and click on it to install. Its free.
With LibreOffice installed you can create and print office documents from your Pi. To print Office
documents from your Android device we need to configure something called a CUPS Filter. We will
leverage LibreOffice to render and print documents that arrive from our Android devices.
Start the File Manager on your Pi and right-click in your home directory and choose Create New ->
Blank File. Create three files named; droid.types , droid.convs and droid. Right-click
droid.types and open it with the LeafPad editor and type the text shown:
#!/bin/bash
# CUPS filter to process multiple file-types using libreoffice
# by BlackSpruce Software for Let's Print Droid
sandbox=${TMPDIR-/tmp}/cups-droid
# remove any previous sandbox
if [ -e "$sandbox" ]; then
rm -rf "$sandbox"
fi
# Create a sandbox
(umask 077 && mkdir $sandbox) || {
echo "Cannot create temporary directory! Exiting."
exit 1
}
# find the filter input file
if [ $# -lt 6 ]; then
fn="$sandbox/input"
cat > "$fn"
else
fn="$6"
fi
echo "Input file is $fn" >> "$sandbox/droid.txt"
# Call libreoffice quietly
libreoffice --headless -convert-to pdf -outdir "$sandbox" "$fn" \
1>>"$sandbox/droid.txt"
# Send PDF to stdout
basename=`basename "$fn"`
destpdf="$sandbox/$basename.pdf"
if [ -e "$destpdf" ]; then
cat "$destpdf"
# success - Erase sandbox
rm -rf "$sandbox"
else
echo "No PDF file! Exiting " >> "$sandbox/droid.txt"
# leave sandbox for trouble shooting
exit 1
fi
Restart CUPS :
sudo service cups restart
Now select an MS Word or Open Office Doc from your Android device using Lets Print Droid and print
to your Pi printer.