Ajout script rotation PDF
authorHugo Villeneuve <hvilleneuve@addenergie.ca>
Tue, 17 Nov 2015 20:11:41 +0000 (15:11 -0500)
committerHugo Villeneuve <hvilleneuve@addenergie.ca>
Fri, 22 Jul 2016 16:19:17 +0000 (12:19 -0400)
scripts/Makefile.am
scripts/hvpdf-rotate [new file with mode: 0755]

index 7e069fa..d5f7271 100644 (file)
@@ -27,6 +27,7 @@ dist_bin_SCRIPTS = \
     source-code-stats \
     flac2ogg flac2mp3 \
     hv-scan \
+    hvpdf-rotate \
     tape-backup tape-backup-mult tape-list tape-restore
 
 
diff --git a/scripts/hvpdf-rotate b/scripts/hvpdf-rotate
new file mode 100755 (executable)
index 0000000..19e4bf6
--- /dev/null
@@ -0,0 +1,33 @@
+#!/bin/bash
+
+print_usage()
+{
+    echo "$(basename $0) -- PDF rotate."
+    echo "Usage: $(basename $0) [OPTIONS...] INPUT-FILE"
+    echo "Options:"
+    echo "  -h   display this help and exit"
+}
+
+if [ "x${1}" = "x--help" ]; then
+    print_usage
+    exit 1
+fi
+
+if [ ${#} -ne 1 ]; then
+    echo "Missing input filename"
+    print_usage
+    exit 1
+fi
+
+src="${1}"
+
+temp=$(mktemp)
+
+gs -sDEVICE=pdfwrite -sOutputFile=${temp} -dNOPAUSE -dBATCH -dEPSCrop \
+   -c "<</Orientation 2>> setpagedevice" -f ${src}
+
+if [ ${?} -eq 0 ]; then
+    mv ${temp} ${src}
+else
+    rm${temp}
+fi