summaryrefslogtreecommitdiff
path: root/Build
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2024-06-13 20:15:25 +0000
committerKarl Berry <karl@freefriends.org>2024-06-13 20:15:25 +0000
commit95e8a1f4641bd5dbb0a14bf499ddb18ef5efa6f8 (patch)
treedc59e62d1b8d655061d9c816d05156ce7980c76b /Build
parent7ba522a8344a0069fd4429fb2c929d8a3d63ae69 (diff)
pdfxup (13jun24)
git-svn-id: svn://tug.org/texlive/trunk@71513 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rwxr-xr-xBuild/source/texk/texlive/linked_scripts/pdfxup/pdfxup134
1 files changed, 101 insertions, 33 deletions
diff --git a/Build/source/texk/texlive/linked_scripts/pdfxup/pdfxup b/Build/source/texk/texlive/linked_scripts/pdfxup/pdfxup
index d31db88f9e5..b7197de00cc 100755
--- a/Build/source/texk/texlive/linked_scripts/pdfxup/pdfxup
+++ b/Build/source/texk/texlive/linked_scripts/pdfxup/pdfxup
@@ -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
@@ -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
@@ -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,
@@ -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;;
*)
@@ -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;
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
##################################################################
##
@@ -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)