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 ecda9f9
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions bin/pdfjam
Original file line number Diff line number Diff line change
Expand Up @@ -198,16 +198,22 @@ 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
else
echo "The 'paper' program seems not to be working; not using it"
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 ecda9f9

Please sign in to comment.