Last active
December 25, 2015 21:48
-
-
Save pmbuko/7044657 to your computer and use it in GitHub Desktop.
Prints a pdf as postscript to an lpr queue. Requires pdf2ps. (http://yourmacguy.wordpress.com/2009/08/18/print-pdfs-as-postscript-to-an-lpr-queue/)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# grab first argument as pdf filename and generate ps filename | |
thePDF=$1 | |
thePS=$(echo $thePDF.ps) | |
queueName=$2 | |
usage() { | |
cat<<EOF | |
Usage: psprint [your pdf] [lpr queue]*" | |
This command does three things:" | |
1. Converts the specified pdf file to ps" | |
2. Prints the ps file to your default lpr queue *(unless you specify another queue)" | |
3. Deletes the ps file" | |
EOF | |
exit 1 | |
} | |
if [ $# == 0 ]; then | |
usage | |
elif [ $# == 1 ]; then | |
echo "Converting $thePDF ..." | |
pdf2ps "$thePDF" "$thePS" | |
echo "Sending to default printer ..." | |
lpr "$thePS" | |
echo "Cleaning up ..." | |
rm "$thePS" | |
exit 0 | |
elif [ $# == 2 ]; then | |
echo "Converting $thePDF ..." | |
pdf2ps "$thePDF" "$thePS" | |
echo "Sending to $2 ..." | |
lpr -P "$queueName" "$thePS" | |
echo "Cleaning up ..." | |
rm "$thePS" | |
exit 0 | |
else | |
usage | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment