mybin

my ~/bin
git clone https://a3nm.net/git/mybin/
Log | Files | Refs | README

commit 32eec499e5fa7f30a356725eaf1719aa1720f7ba
parent 02b1066efa142a6e66aa58e6642837b700a73945
Author: Antoine Amarilli <a3nm@a3nm.net>
Date:   Thu,  9 Jul 2020 15:49:54 +0200

pdfpagecat

Diffstat:
pdfpagecat | 24++++++++++++++++++++++++
1 file changed, 24 insertions(+), 0 deletions(-)

diff --git a/pdfpagecat b/pdfpagecat @@ -0,0 +1,24 @@ +#!/bin/bash + +# concatenate PDF files, introducing blank pages when necessary, for duplex +# printing + +nargs=() + +if [ -t 1 ] ; then + echo "stdout should be the output file, not a terminal" + exit 1 +fi + +for f in "$@" +do + nargs+=("$f") + NP=$(pdfinfo "$f" | grep '^Pages:' | awk '{print $2}') + if [ $((NP % 2)) -eq 1 ] + then + nargs+=($HOME/git/misc/blank_a4.pdf) + fi +done + +pdftk "${nargs[@]}" cat output - +