Last active
October 3, 2015 08:27
-
-
Save tskrynnyk/2424894 to your computer and use it in GitHub Desktop.
Converting PDF file into booklet.
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 | |
| # pdf2book: Converting PDF file into booklet | |
| ERR=0 | |
| for i in pdftops psbook psnup; do | |
| if [ ! "$(which $i)" ]; then | |
| echo Error: $i not found | |
| ERR=1 | |
| fi | |
| done | |
| [ "$ERR" -eq 1 ] && exit 1 | |
| FILE_PDF="$1" | |
| FILE_PS="${FILE_PDF%%.pdf}-book.ps" | |
| #pdftops "$FILE_PDF" - | psbook | psnup -2 >$FILE_PS | |
| pdftops -level3 -paper A4 "$FILE_PDF" - | psbook | psnup -2 >"$FILE_PS" | |
| cat <<EOF | |
| Print: | |
| lp -o page-set=even -o outputorder=reverse "$FILE_PS" | |
| lp -o page-set=odd "$FILE_PS" && rm "$FILE_PS" | |
| EOF | |
| #echo "Do you wish to continue? (y/n)" | |
| read -n1 -t10 -p "Print this document? [y/N]: " answer | |
| echo | |
| case $answer in | |
| Y|y) | |
| echo OK | |
| ;; | |
| N|n) | |
| echo No | |
| ;; | |
| *) | |
| ;; | |
| esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment