Troels Kofoed Jacobsen’s blog


Print pdf files from bash
April 25, 2008, 12:14 pm
Filed under: bash | Tags: , ,

Tired of manually doing pdf2ps and then lpr so you can print from the commandline. This bash function is the solution.


function printpdf ()
{
for i in $@; do
if [ "$1" != "$i" ]; then
dt=`date +%y%m%d%H%M%S`
pdftops $i temp-print${dt}.ps
lpr -P $1 temp-print${dt}.ps
rm temp-print${dt}.ps
fi
done
}

Usage:
printpdf printername file1.pdf file2.pdf file3.pdf ….


No Comments Yet so far
Leave a comment



Leave a comment
Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>