Skip to content

Commit

Permalink
Sanity-check the output of 'paper'
Browse files Browse the repository at this point in the history
  • Loading branch information
rrthomas committed Apr 30, 2024
1 parent a872527 commit 6852d18
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions bin/pdfjam
Original file line number Diff line number Diff line change
Expand Up @@ -198,16 +198,20 @@ preamble='' ## Default LaTeX preamble string.
##
## Get default paper size from libpaper >= 2 if possible, otherwise guess A4
##
paperspec=
if command -v paper >/dev/null ; then
paperspec=$(paper)
paperdimensions=$(echo "$paperspec" | cut -f 2 -d " ")
paperunit=$(echo "$paperspec" | cut -f 3 -d " ")
if test "$paperunit" = "pt"; then paperunit=bp; fi
paperwidth=$(echo "$paperdimensions" | cut -f 1 -d "x")
paperheight=$(echo "$paperdimensions" | cut -f 2 -d "x")
papersize="papersize={$paperwidth$paperunit,$paperheight$paperunit}"
paper='' ## We might not have a LaTeX-compatible name
else
if echo "$paperspec" | grep -q '^.*: '; then
paperdimensions=$(echo "$paperspec" | cut -f 2 -d " ")
paperunit=$(echo "$paperspec" | cut -f 3 -d " ")
if test "$paperunit" = "pt"; then paperunit=bp; fi
paperwidth=$(echo "$paperdimensions" | cut -f 1 -d "x")
paperheight=$(echo "$paperdimensions" | cut -f 2 -d "x")
papersize="papersize={$paperwidth$paperunit,$paperheight$paperunit}"
paper='' ## We might not have a LaTeX-compatible name
fi
fi
if test -z "$paperspec"; then
paper='a4paper' ## fallback paper size is ISO A4
papersize='' ## clear papersize
fi
Expand Down

0 comments on commit 6852d18

Please sign in to comment.