Created
August 30, 2020 12:09
-
-
Save jeeger/904219de7045b5f99bcd7832594f0931 to your computer and use it in GitHub Desktop.
Tile Burda pattern
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 | |
NUPX="${1%%x*}" | |
NUPY="${1##*x}" | |
PAGESTART="${2%%-*}" | |
PAGEEND="${2##*-}" | |
FILE="$3" | |
# TODO: Check file and values. | |
PAGESIZES="$(pdfinfo -box -f "$PAGESTART" -l "$PAGEEND" "$FILE" | awk '/[0-9]+ size:/ {print $4 "x" $6}')" | |
PAGESIZEX="${PAGESIZES%%x*}" | |
PAGESIZEY="${PAGESIZES##*x}" | |
RANGES=() | |
STARTPAGES="$(seq $((PAGEEND-NUPX + 1)) -"$NUPX" "$PAGESTART")" | |
for startpage in $STARTPAGES; do | |
RANGES+=("$startpage-$((startpage + NUPX - 1))") | |
done | |
PDFJAM_RANGES=$(IFS=","; echo "${RANGES[*]}") | |
LANG=C TOTALSIZE="$(printf "{%.3fpt,%.3fpt}" "$(echo "$NUPX * $PAGESIZEX" | bc)" "$(echo "$NUPY * $PAGESIZEY" | bc)")" | |
pdfjam --papersize "$TOTALSIZE" --nup "$NUPX"x"$NUPY" --outfile "${FILE%%.pdf}-joined.pdf" -- "$FILE" "$PDFJAM_RANGES" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment