summaryrefslogtreecommitdiff
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
parent7ba522a8344a0069fd4429fb2c929d8a3d63ae69 (diff)
pdfxup (13jun24)
git-svn-id: svn://tug.org/texlive/trunk@71513 c570f23f-e606-0410-a88d-b1316a301751
-rwxr-xr-xBuild/source/texk/texlive/linked_scripts/pdfxup/pdfxup134
-rw-r--r--Master/texmf-dist/doc/man/man1/pdfxup.12
-rw-r--r--Master/texmf-dist/doc/man/man1/pdfxup.man1.pdfbin28280 -> 28364 bytes
-rw-r--r--Master/texmf-dist/doc/support/pdfxup/README4
-rw-r--r--Master/texmf-dist/doc/support/pdfxup/RELEASES4
-rw-r--r--Master/texmf-dist/doc/support/pdfxup/doc/Makefile3
-rw-r--r--Master/texmf-dist/doc/support/pdfxup/doc/pdfxup-doc.pdf (renamed from Master/texmf-dist/doc/support/pdfxup/pdfxup.pdf)bin90128 -> 94798 bytes
-rw-r--r--Master/texmf-dist/doc/support/pdfxup/doc/pdfxup-doc.tex163
-rw-r--r--Master/texmf-dist/doc/support/pdfxup/doc/pdfxup.pdfbin0 -> 96697 bytes
-rwxr-xr-xMaster/texmf-dist/scripts/pdfxup/pdfxup134
10 files changed, 375 insertions, 69 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)
diff --git a/Master/texmf-dist/doc/man/man1/pdfxup.1 b/Master/texmf-dist/doc/man/man1/pdfxup.1
index 8ca0c2b394a..49851a17f0b 100644
--- a/Master/texmf-dist/doc/man/man1/pdfxup.1
+++ b/Master/texmf-dist/doc/man/man1/pdfxup.1
@@ -1,6 +1,6 @@
.\" Manpage for pdfxup.
.\" Contact pdfxup@markey.fr to correct errors or typos.
-.TH man 1 "24 april 2021" "2.10" "pdfxup man page"
+.TH man 1 "11 june 2024" "2.12" "pdfxup man page"
.SH NAME
pdfxup \- n-up tool with reduced margins
.SH SYNOPSIS
diff --git a/Master/texmf-dist/doc/man/man1/pdfxup.man1.pdf b/Master/texmf-dist/doc/man/man1/pdfxup.man1.pdf
index ee969aeab10..cb37cc77b65 100644
--- a/Master/texmf-dist/doc/man/man1/pdfxup.man1.pdf
+++ b/Master/texmf-dist/doc/man/man1/pdfxup.man1.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/support/pdfxup/README b/Master/texmf-dist/doc/support/pdfxup/README
index 335ae71dd88..7bbb705d4c6 100644
--- a/Master/texmf-dist/doc/support/pdfxup/README
+++ b/Master/texmf-dist/doc/support/pdfxup/README
@@ -1,4 +1,4 @@
-PDFXUP -- v2.11 (2024/03/15)
+PDFXUP -- v2.12 (2024/06/11)
N. Markey <pdfxup@markey.fr>
@@ -18,7 +18,7 @@ graphicx package) in order to produce the new document.
-%% (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
diff --git a/Master/texmf-dist/doc/support/pdfxup/RELEASES b/Master/texmf-dist/doc/support/pdfxup/RELEASES
index b6272603a33..f0e9b936432 100644
--- a/Master/texmf-dist/doc/support/pdfxup/RELEASES
+++ b/Master/texmf-dist/doc/support/pdfxup/RELEASES
@@ -65,3 +65,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)
diff --git a/Master/texmf-dist/doc/support/pdfxup/doc/Makefile b/Master/texmf-dist/doc/support/pdfxup/doc/Makefile
new file mode 100644
index 00000000000..ea9fe01b2fb
--- /dev/null
+++ b/Master/texmf-dist/doc/support/pdfxup/doc/Makefile
@@ -0,0 +1,3 @@
+all:
+ pdflatex pdfxup-doc.tex
+ pdfxup -o pdfxup.pdf pdfxup-doc.pdf
diff --git a/Master/texmf-dist/doc/support/pdfxup/pdfxup.pdf b/Master/texmf-dist/doc/support/pdfxup/doc/pdfxup-doc.pdf
index 2c629a8b2ef..cf3f9af9365 100644
--- a/Master/texmf-dist/doc/support/pdfxup/pdfxup.pdf
+++ b/Master/texmf-dist/doc/support/pdfxup/doc/pdfxup-doc.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/support/pdfxup/doc/pdfxup-doc.tex b/Master/texmf-dist/doc/support/pdfxup/doc/pdfxup-doc.tex
new file mode 100644
index 00000000000..c051d0483f5
--- /dev/null
+++ b/Master/texmf-dist/doc/support/pdfxup/doc/pdfxup-doc.tex
@@ -0,0 +1,163 @@
+\documentclass{article}
+\usepackage[margin=6cm]{geometry}
+\usepackage{tikz}
+\usepackage{xspace}
+\def\pdfxup{\texttt{pdfxup}\xspace}
+
+\begin{document}
+\title{\pdfxup \\[2mm]
+ \normalsize
+ version 2.12 -- 2024/06/11}
+\author{Nicolas Markey}
+\date{}
+
+\maketitle
+
+\def\abstractname{}
+\begin{abstract}
+\pdfxup is a shell script that creates $n$-up PDF documents, while at
+the same time removing as much white stripes as possible. This
+document reviews the main features of \pdfxup. See the \verb+man+ page
+for more details.
+\end{abstract}
+
+\section{Basic usage}
+Running \pdfxup with no options creates a 2-up document from the
+original PDF file:
+\begin{center}
+\begin{tikzpicture}[scale=1.5]
+ \begin{scope}
+ \draw (0,0) |- (1.1,1.5) |- cycle;
+ \foreach \x in {.3,.4,...,.9}
+ {\draw [line width=.5mm,black!50!white] (.2,\x) -- +(.7,0);}
+ \draw [line width=.5mm,black!50!white] (.3,1.1) -- +(.5,0);
+ \end{scope}
+ \begin{scope}[xshift=1.2cm]
+ \draw (0,0) |- (1.1,1.5) |- cycle;
+ \foreach \x in {.3,.4,...,1.2}
+ {\draw [line width=.5mm,black!50!white] (.2,\x) -- +(.7,0);}
+ %\draw [line width=.5mm,black!50!white] (.3,1.2) -- +(.4,0);
+ \end{scope}
+ %
+ \draw[->] (2.6,.7) -- +(1,0);% node[midway,above] {scale=97\%};
+ %
+ \begin{scope}[yshift=2mm,xshift=4cm]
+ \draw (0,0) |- (1.5,1.1) |- cycle;
+ \begin{scope}[yshift=-1.8mm,xshift=-1.5mm,scale=.97]
+ \draw[line width=.02pt] (.178,.25) |- (.922,1.25) |- cycle;
+ \foreach \x in {.3,.4,...,.9}
+ {\draw [line width=.5mm,black!50!white] (.2,\x) -- +(.7,0);}
+ \draw [line width=.5mm,black!50!white] (.3,1.1) -- +(.5,0);
+ \begin{scope}[xshift=7.5mm]
+ \draw[line width=.02pt] (.178,.25) |- (.922,1.25) |- cycle;
+ \foreach \x in {.3,.4,...,1.2}
+ {\draw [line width=.5mm,black!50!white] (.2,\x) -- +(.7,0);}
+ \end{scope}
+ \end{scope}
+ \end{scope}
+\end{tikzpicture}
+\end{center}
+
+It removes white strips around text, so that it does not need to scale
+down the original document too much. All margins in the resulting PDF
+can be adapted using various options. The number of rows and columns
+of pages can be modified using options \verb+-x+ and \verb+-y+. By
+default, the output file is in landscape mode, but this can be changed
+using option \verb+-l=no+.
+
+Computing the boundig box is performed automatically using
+GhostScript. This may take time for long documents, but it is often
+sufficient to compute the bounding box on the first few pages, using
+option \verb+-bb+. Bounding-box computation can be turned off (so that
+original margins are kept) using \verb+-kbb+.
+
+It is possible to only include a subset of pages using option
+\verb+-p+ (notice that if a page is listed twice, it will be included
+twice).
+
+\section{Creating a booklet}
+\pdfxup can create booklets: this is similar to the operation above,
+but the pages are ordered and oriented in the adequate way. Booklet
+mode is triggered with the \verb+-b+ option.
+\begin{center}
+\begin{tikzpicture}[scale=1.5]
+ \begin{scope}
+ \draw (0,0) |- (1.1,1.5) |- cycle;
+ \foreach \x in {.3,.4,...,.9}
+ {\draw [line width=.5mm,black!50!white] (.2,\x) -- +(.7,0);}
+ \draw [line width=.5mm,black!50!white] (.3,1.1) -- +(.5,0);
+ \end{scope}
+ \begin{scope}[xshift=1.2cm]
+ \draw (0,0) |- (1.1,1.5) |- cycle;
+ \foreach \x in {.3,.4,...,1.2}
+ {\draw [line width=.5mm,black!50!white] (.2,\x) -- +(.7,0);}
+ %\draw [line width=.5mm,black!50!white] (.3,1.2) -- +(.4,0);
+ \end{scope}
+ %
+ \draw[->] (2.6,.7) -- +(1,0);% node[midway,above] {scale=97\%};
+ %
+ \begin{scope}[yshift=2mm,xshift=4cm]
+ \draw (0,0) |- (1.5,1.1) |- cycle;
+ \begin{scope}[yshift=-1.8mm,xshift=6mm,scale=.97]
+% \draw[line width=.02pt] (.178,.25) |- (.922,1.25) |- cycle;
+ \foreach \x in {.3,.4,...,.9}
+ {\draw [line width=.5mm,black!50!white] (.2,\x) -- +(.7,0);}
+ \draw [line width=.5mm,black!50!white] (.3,1.1) -- +(.5,0);
+ \end{scope}
+ \fill[white] (1.2,-.01) -| (1.51,.3) -- cycle;
+ \draw[fill=white] (1.2,0) .. controls +(40:2mm) and +(-60:2mm) .. (1.2,.35) -- (1.5,.3) -- cycle;
+ \begin{scope}
+ \draw[clip] (1.2,0) .. controls +(40:2mm) and +(-60:2mm) .. (1.2,.35) -- (1.5,.3) -- cycle;
+ \draw[line width=.5mm,black!50!white] (1.3,.3) .. controls +(-60:1mm) and +(90:2mm) .. ++(-80:3mm);
+ \draw[line width=.5mm,black!50!white] (1.38,.28) .. controls +(-69:1mm) and +(90:2mm) .. ++(-80:3mm);
+ \end{scope}
+ \end{scope}
+\end{tikzpicture}
+\end{center}
+
+\section{Watermarking}
+Using option \verb+-w+, you can add watermarking to the original file:
+\begin{center}
+\begin{tikzpicture}[scale=1.5]
+ \begin{scope}
+ \draw (0,0) |- (1.1,1.5) |- cycle;
+ \foreach \x in {.3,.4,...,.9}
+ {\draw [line width=.5mm,black!50!white] (.2,\x) -- +(.7,0);}
+ \draw [line width=.5mm,black!50!white] (.3,1.1) -- +(.5,0);
+ \end{scope}
+ \begin{scope}[xshift=1.2cm]
+ \draw (0,0) |- (1.1,1.5) |- cycle;
+ \foreach \x in {.3,.4,...,1.2}
+ {\draw [line width=.5mm,black!50!white] (.2,\x) -- +(.7,0);}
+ %\draw [line width=.5mm,black!50!white] (.3,1.2) -- +(.4,0);
+ \end{scope}
+ %
+ \draw[->] (2.6,.7) -- +(1,0);% node[midway,above] {scale=97\%};
+ %
+ \begin{scope}[yshift=2mm,xshift=4cm]
+ \draw (0,0) |- (1.5,1.1) |- cycle;
+ \begin{scope}[yshift=-1.8mm,xshift=-1.5mm,scale=.97]
+ \path (.178,.5) -- (.922,1) node[midway,sloped,opacity=.5]
+ {\bfseries\large draft};
+ \draw[line width=.02pt] (.178,.25) |- (.922,1.25) |- cycle;
+ \foreach \x in {.3,.4,...,.9}
+ {\draw [line width=.5mm,black!50!white] (.2,\x) -- +(.7,0);}
+ \draw [line width=.5mm,black!50!white] (.3,1.1) -- +(.5,0);
+ \begin{scope}[xshift=7.5mm]
+ \path (.178,.5) -- (.922,1) node[midway,sloped,opacity=.5]
+ {\bfseries\large draft};
+ \draw[line width=.02pt] (.178,.25) |- (.922,1.25) |- cycle;
+ \foreach \x in {.3,.4,...,1.2}
+ {\draw [line width=.5mm,black!50!white] (.2,\x) -- +(.7,0);}
+ \end{scope}
+ \end{scope}
+ \end{scope}
+\end{tikzpicture}
+\end{center}
+
+
+\pdfxup has many other options, setting up margins, frames, order of pages,~...
+Please look at the \texttt{man} page for more details.
+
+
+\end{document}
diff --git a/Master/texmf-dist/doc/support/pdfxup/doc/pdfxup.pdf b/Master/texmf-dist/doc/support/pdfxup/doc/pdfxup.pdf
new file mode 100644
index 00000000000..7fda750bff7
--- /dev/null
+++ b/Master/texmf-dist/doc/support/pdfxup/doc/pdfxup.pdf
Binary files differ
diff --git a/Master/texmf-dist/scripts/pdfxup/pdfxup b/Master/texmf-dist/scripts/pdfxup/pdfxup
index d31db88f9e5..b7197de00cc 100755
--- a/Master/texmf-dist/scripts/pdfxup/pdfxup
+++ b/Master/texmf-dist/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)