Created
October 15, 2015 03:15
-
-
Save omsai/35114b25a084c5cdbf02 to your computer and use it in GitHub Desktop.
Print double sided PDF documented interactively with HP DeskJet F4480
This file contains hidden or 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 | |
# Use realpath for tilde expansion | |
pdf_file=$(realpath "${1}") | |
# Usage message if file does not exist | |
if ! [ -e "${pdf_file}" ] ; then | |
echo -e "Usage: $(basename $0) <pdf_file> | |
Double-sided printing. First prints the odd pages in reverse order, | |
then the even pages." | |
exit 1 | |
fi | |
# Count the number of pages | |
sides=$( pdfinfo "${pdf_file}" | grep Pages | cut -d ' ' -f 2- | tr -d '[[:space:]]' ) | |
pages=$( expr $sides / 2 + $sides % 2 ) | |
# Tell the user how many papers to load into the printer tray | |
echo "Please load $pages pages onto the printer tray and ENTER to continue." | |
read -s | |
lp -o outputorder=reverse \ | |
-o page-set=odd \ | |
"${pdf_file}" | |
echo "Reload the printed pages and ENTER to continue." | |
read -s | |
lp -o outputorder=normal \ | |
-o page-set=even \ | |
"${pdf_file}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment