I found a simple and (in my view) elegant way to make users able to print pdf-files - even if they are not on the LAN, even from cell phones and other devices without installing printer drivers etc. It is based on this:
https://www.linux.com/comment/6798. Users simply attach their pdf-files to an email, and send this email to a specific address.
First, create a user to receive the emails with attached pdf-files. The user name should be simple to remember, but hard to guess for strangers. Here I'll call the user "printpdf" for convience. Switch to the new user's home directory and create the file .fetchmailrc with this content:
poll yourserver.org
proto POP3
user printpdf
pass printpdfpasswordHere, yourserver.org and printpdfpassword should of course be replaced with your local settings.
Also create a file, autoprint.sh, with this content:
#!/bin/bash
SUPPORTED_FILETYPES=".pdf"
LP_OPTIONS="-d Yourprintername -o media=A4,tray1 -o fit-to-page -o position=top -o scaling=100"
FILENAME=$(date +%H%M%S).txt
/usr/bin/fetchmail -s --bsmtp ~/mailtemp/$FILENAME
if [ "$?" = "0" ]; then
/usr/bin/uudeview +e $SUPPORTED_FILETYPES -p ~/printable -i ~/mailtemp/$FILENAME
rm ~/mailtemp/$FILENAME
for f in ~/printable/*
do
lp $LP_OPTIONS "$f"
rm "$f"
done
fiPlease replace "Yourprintername" with the name of your local printer to use. Also, you may want to change LP_OPTIONS according to your hardware and needs.
Then you need to create the relevant folders and make sure the ownerships are ok:
$ mkdir mailtemp
$ mkdir printable
$ chown -R printpdf mailtemp printable .fetchmailrc
$ chmod 600 .fetchmailrc
$ chmod 700 autoprint.shYou will also need to install the uudeview package. I did it like this:
$ cd /tmp
$ wget ftp://ftp.pbone.net/mirror/pkgs.repoforge.org/uudeview/uudeview-0.5.20-2.el6.rf.x86_64.rpm
$ yum localinstall uudeview-0.5.20-2.el6.rf.x86_64.rpmFinally, you should put an entry in the crontab to make the script run as user printpdf every 5 minutes or so. Create the file /etc/e-smith/templates-custom/etc/crontab/autoprint with this content:
*/5 * * * * printpdf /home/e-smith/files/users/printpdf/autoprint.shAnd do
/sbin/e-smith/expand-template /etc/crontabObviously this solution can be improved in many ways. But for me and some of my users, it's really convenient. E.g. when you on your phone receive an email with an attached pdf. You simply forward the email to printpdf@yourserver.org, and after a few minutes, the pdf is printed.
What do you think?
/Jesper H