summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkaa <kaa@disroot.org>2024-07-25 14:08:52 -0700
committerkaa <kaa@disroot.org>2024-07-25 14:08:52 -0700
commit41ac0aba1a98718068d86f2934130fcfe70d5ea6 (patch)
treefde24a04c44515182fde73b9062411ddf654398b
Public release.
-rwxr-xr-xpdfdouble29
1 files changed, 29 insertions, 0 deletions
diff --git a/pdfdouble b/pdfdouble
new file mode 100755
index 0000000..38ef116
--- /dev/null
+++ b/pdfdouble
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+in="$1"
+if [ -z "$in" ] || ! [ -f "$in" ]
+then
+ echo Provide an input PDF.
+ return
+fi
+
+s() {
+ seq $1 -2 $2 | tr '\n' ',' | sed -e 's/,$//'
+}
+pages=$(mutool info "$in" | grep '^Pages: ' | sed -e 's/.* //')
+base="${in%.*}"
+if [ $((pages % 2)) -eq 0 ]
+then
+ echo Even
+ mutool draw -o "$base"-e.pdf "$in" $(s $pages 2)
+ mutool draw -o "$base"-o.pdf "$in" $(s $((pages - 1)) 1)
+else
+ mutool draw -o "$base"-e.pdf "$in" $(s $((pages - 1)) 2)
+ mutool draw -o "$base"-o.pdf "$in" $(s $pages 1)
+fi
+
+echo '
+1. Print odd. They may be more odd pages than even,
+ but not more even than odd.
+2. Flip.
+3. Print even.'