Last active
October 8, 2015 03:38
-
-
Save pi8027/3272100 to your computer and use it in GitHub Desktop.
中綴じ用の面付けをするスクリプト
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/zsh | |
[ -z $1 ] && exit -1 | |
nakatoji_sequence(){ | |
last=$((4 * $1)) | |
for i in {1..$1} ; do | |
echo -n "$(($last - $i * 2 + 2)),$(($i * 2 - 1))," | |
echo -n "$(($i * 2)),$((1 + $last - $i * 2))," | |
done | sed "s/,$//g" | |
} | |
file=$(echo $1 | sed "s/\.pdf$//g") | |
pages=$(pdfinfo $file.pdf | grep Pages | sed "s/^.*: *//g") | |
pdfjam --outfile /dev/stdout $file.pdf -,{},{},{} 2>/dev/null | \ | |
pdfjam --nup 2x1 --landscape --outfile ${file}_nakatoji.pdf \ | |
/dev/stdin $(nakatoji_sequence $((( $pages + 3 ) / 4))) 2>/dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment