Skip to content

Commit

Permalink
pdfxup (13jun24)
Browse files Browse the repository at this point in the history
git-svn-id: svn://tug.org/texlive/trunk/Build/source@71513 c570f23f-e606-0410-a88d-b1316a301751
  • Loading branch information
kberry committed Jun 13, 2024
1 parent d4f3c09 commit c763400
Showing 1 changed file with 101 additions and 33 deletions.
134 changes: 101 additions & 33 deletions texk/texlive/linked_scripts/pdfxup/pdfxup
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
shopt -s extglob
shopt -s lastpipe

VERSION="2.11"
VDATE="2024/03/15"
VERSION="2.12"
VDATE="2024/06/11"
## see release notes at the end of this file.


## (c) 2024/03/15 Nicolas Markey <pdfxup at markey dot fr>
## (c) 2024/06/11 Nicolas Markey <pdfxup at markey dot fr>
##
## This work may be distributed and/or modified under the conditions of
## the LaTeX Project Public License, either version 1.3 of this license
Expand Down Expand Up @@ -392,17 +392,17 @@ function cleancslor()
fi
;;
-+([0-9]))
if [[ $i -le $nbp ]]; then
if [[ ${i%-} -le $nbp ]]; then
result+="1$i,";
nbpages+=${i#-};
else
myecho 1+ " $file has $nbp page(s); changed 1$i to 1-$nbp."
myecho 1+ " $file has $nbp page(s); changed range 1$i to 1-$nbp."
result+="1$nbp,";
nbpages+=${nbp#-};
fi
;;
+([0-9])-)
if [[ $i -le $nbp ]]; then
if [[ ${i%-} -le $nbp ]]; then
result+="$i$nbp,";
nbpages+=$(expr $nbp + 1 - ${i%-});
else
Expand All @@ -427,6 +427,20 @@ function cleancslor()
-)
result+="1-$nbp,";
nbpages+=$nbp;;
%+([0-9]))
## explicitly list all values...
## (simpler, but admitedly less efficient,
## than handling real modulos)
declare -i cptr;
cptr=1;
step=`echo $i|cut -d% -f2`;
while [[ $cptr -le $nbp ]]; do
if [[ $cptr -gt 0 ]]; then
result+="$cptr,";
nbpages+=1;
fi
cptr+=$step;
done;;
+([0-9])%+([0-9]))
## explicitly list all values...
## (simpler, but admitedly less efficient,
Expand All @@ -435,8 +449,25 @@ function cleancslor()
cptr=`echo $i|cut -d% -f1`;
step=`echo $i|cut -d% -f2`;
while [[ $cptr -le $nbp ]]; do
result+="$cptr,";
nbpages+=1;
if [[ $cptr -gt 0 && $cptr -le $nbp ]]; then
result+="$cptr,";
nbpages+=1;
fi
cptr+=$step;
done;;
+([0-9])%+([0-9]-+([0-9])))
## explicitly list all values...
## (simpler, but admitedly less efficient,
## than handling real modulos)
declare -i cptr;
cptr=`echo $i|cut -d% -f1`;
step=`echo $i|cut -d% -f2|cut -d- -f1`;
last=`echo $i|cut -d% -f2|cut -d- -f2`;
while [[ $cptr -le $last ]]; do
if [[ $cptr -gt 0 && $cptr -le $nbp ]]; then
result+="$cptr,";
nbpages+=1;
fi
cptr+=$step;
done;;
*)
Expand Down Expand Up @@ -690,22 +721,28 @@ while [ $# != 0 ]; do
shift;;
-p|--pages|--page)
case $2 in
-)
+([0-9,\-%]))
PAGES+="$2,";
;;
-*)
echo "Error: option '$1' expects a range, not '$2'.";
*)
echo "Error: option '$1' expects a set of pages, not '$2'.";
echo "Aborting.";
exit 0;
;;
*)
PAGES+="$2,";
;;
esac
shift 2;;
-p*|--page*)
-p=*|--pages?=*)
ANS=`echo $1|sed -re "s/--?p(ages?)?=?//"`;
PAGES+="$ANS,";
case $ANS in
+([0-9,\-%]))
PAGES+="$ANS,";
;;
*)
echo "Error: option '$1' expects a set of pages, not '$ANS'.";
echo "Aborting.";
exit 0;
;;
esac
shift;;
-o|--out|--output-file|--outfile)
OUTPUTFILE=$2;
Expand Down Expand Up @@ -837,41 +874,53 @@ while [ $# != 0 ]; do
shift;;
-nobb|--nobb|-no-bb|--no-bb)
case $2 in
-)
+([0-9,\-%]))
EXCLUDE_FOR_BBOX+="$2,";
;;
-*)
echo "Error: option '$1' expects a range, not '$2'.";
*)
echo "Error: option '$1' expects a set of pages, not '$2'.";
echo "Aborting.";
exit 0;
;;
*)
EXCLUDE_FOR_BBOX+="$2,";
;;
esac
shift 2;;
-nobb*|--no-bb*)
ANS=`echo $1|sed -re "s/--?no-?bb=?//"`;
EXCLUDE_FOR_BBOX+="$ANS,";
case $ANS in
+([0-9,\-%]))
EXCLUDE_FOR_BBOX+="$ANS,";
;;
*)
echo "Error: option '$1' expects a set of pages, not '$ANS'.";
echo "Aborting.";
exit 0;
;;
esac
shift;;
-bb|--bb|--bounding-box)
case $2 in
-)
+([0-9,\-%]))
INCLUDE_FOR_BBOX+="$2,";
;;
-*)
echo "Error: option '$1' expects a range, not '$2'.";
*)
echo "Error: option '$1' expects a set of pages, not '$2'.";
echo "Aborting.";
exit 0;
;;
*)
INCLUDE_FOR_BBOX+="$2,";
;;
esac
shift 2;;
-bb*|--bb*|--bounding-box)
ANS=`echo $1|sed -re "s/--?b(ounding-?)?b(ox)?=?//"`;
INCLUDE_FOR_BBOX+="$ANS,";
case $ANS in
+([0-9,\-%]))
INCLUDE_FOR_BBOX+="$ANS,";
;;
*)
echo "Error: option '$1' expects a set of pages, not '$ANS'.";
echo "Aborting.";
exit 0;
;;
esac
shift;;
-kbb|--keepbb|--keep-bb|--original-bb)
case $2 in
Expand Down Expand Up @@ -1008,17 +1057,23 @@ while [ $# != 0 ]; do
shift;;
-*)
usage;;
*:+([0-9\-,\%]))
*:+([0-9\-,%]))
ARG=$1;
file=${ARG%:*};
PAGES+="${ARG#*:},";
## only one file is allowed, and no options
## should appear after the file name...
if [[ $2 ]]; then
echo "All options after PDF file ($1) will be dropped.";
fi
break;;
*)
file=$1;
## only one file is allowed, and no options
## should appear after the file name...
if [[ $2 ]]; then
echo "All options after PDF file ($1) will be dropped.";
fi
break;;
esac;
done
Expand Down Expand Up @@ -1223,6 +1278,7 @@ nbwp=1; ## set even if no watemark
if [[ $WATERMARK_FILE != "" ]]; then
if [[ ! -e $WATERMARK_FILE ]]; then
myecho 1+ " pdfxup: watermarking file not found. Omiting watermarking."
WATERMARK_FILE=""
else
myecho 2+ " * using file $WATERMARK_FILE for watermarking";
fi
Expand Down Expand Up @@ -1259,7 +1315,11 @@ if [[ $KEEP_ORIG_BBOX == 0 ]]; then
if [[ $SBB == 0 ]]; then
myecho 1+ -n "-> computing bounding box";
myecho 2+ "";


## This does not correctly handles EXCLUDE_FOR_BBOX; actually, option -nobb is ignored
## when page range or -bb is used. Best way of handling this would be to range over all pages
## and test if page should be included. -nobb should then have priority over -bb (for pages
## that would be listed in both of them)
for r in ${INCLUDE_FOR_BBOX//,/$IFS};
do
case $r in
Expand Down Expand Up @@ -1561,10 +1621,14 @@ pdfxup has numerous options:
name the resulting file booklet.pdf.
# pdfxup -kbb -x1 -y2 -l0 beamer-frames.pdf
-> arranges 2 beamer frames per page (not reducing margins)
Version 2.00 introduces config files; using beamer2.xup
config file, you can equivalently do
pdfxup -cf beamer2.xup beamer-frames.pdf
# pdfxup -kbb -x2 -y2 -l1 beamer-frames.pdf
pdfxup -cf beamer4.xup beamer-frames.pdf
-> arranges 4 beamer frames per page (not reducing margins)
# pdfxup -fw0 -w draft.png file.pdf
-> remove frame border; add 'draft' watermarking on all pages
-> no frame border; add 'draft' watermarking on all pages
##################################################################
##
Expand Down Expand Up @@ -1633,3 +1697,7 @@ v2.10 (2021/04/25)
v2.11 (2024/03/15)
- fixed a bug in testdim, which did not support fractional values
(bug reported by Walt Tuvell)
v2.12 (2024/06/11)
- fixed several bugs related with page ranges (bugs reported by
Sanjoy Mahajan)

0 comments on commit c763400

Please sign in to comment.