diff options
author | Karl Berry <karl@freefriends.org> | 2020-12-18 22:11:58 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2020-12-18 22:11:58 +0000 |
commit | 000818f10ed9129bc36bd9b55b4e2ea63c223dbf (patch) | |
tree | b8620a897f8ff7efcb19a1460e84d437952f7903 /Master | |
parent | 170c4fd9c3efefe9c24f5886b910e5d2fc9884b5 (diff) |
pdfxup (18dec20)
git-svn-id: svn://tug.org/texlive/trunk@57166 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/man/man1/pdfxup.1 | 138 | ||||
-rw-r--r-- | Master/texmf-dist/doc/man/man1/pdfxup.man1.pdf | bin | 22314 -> 26318 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/support/pdfxup/README | 4 | ||||
-rw-r--r-- | Master/texmf-dist/doc/support/pdfxup/RELEASES | 15 | ||||
-rw-r--r-- | Master/texmf-dist/doc/support/pdfxup/pdfxup.pdf | bin | 89691 -> 89505 bytes | |||
-rwxr-xr-x | Master/texmf-dist/scripts/pdfxup/pdfxup | 1083 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/pdfxup/beamer2.xup | 31 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/pdfxup/beamer4.xup | 31 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/pdfxup/pdfxup-template.tex | 278 | ||||
-rwxr-xr-x | Master/tlpkg/libexec/ctan2tds | 1 |
10 files changed, 1009 insertions, 572 deletions
diff --git a/Master/texmf-dist/doc/man/man1/pdfxup.1 b/Master/texmf-dist/doc/man/man1/pdfxup.1 index 57b547e524d..5fe8a3e054a 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 "21 october 2020" "1.61" "pdfxup man page" +.TH man 1 "17 december 2020" "2.00" "pdfxup man page" .SH NAME pdfxup \- n-up tool with reduced margins .SH SYNOPSIS @@ -22,14 +22,26 @@ package) in order to produce the new document. pdfxup accepts numerous options. The most important ones are: .\" additional options should be lister here... .TP -\fB\-x\fR n, \fB\-\-columns\fR n -sets the number of columns in the output file (default 2); +\fB\-x\fR m, \fB\-\-columns\fR m +sets the number of columns of the output file (default 2); .TP \fB\-y\fR n, \fB\-\-rows\fR n -sets the number of lines in the output file (default 1); +sets the number of lines of the output file (default 1); .TP -\fB\-l\fR, \fB\-\-landscape\fR -sets orientation of paper (of final document) landscape; +\fB\-nup\fR m\fBx\fRn, \fB\--nup\fR m\fBx\fRn +sets the number of rows and columns of the output file (default 2x1); +.TP +\fB\-l\fR (0|1), \fB\-\-landscape\fR, \fB\-\-portrait\fR +sets orientation of paper (of final document); +.TP +\fB\-cf\fR file, \fB\-\-config \fR file, \fB\-\-mode \fR file +reads file (with extension \fB.xup\fR) and uses options defined in that +file (see below for details about \fB.xup\fR files). +All options are processed in the order the appear on the command-line, +so that it is possible to modify the options set in the configuration +file (and it is even possible to include several configuration files, the +later one overwriting the options set by the previous ones). +Files are looked-up using kpsewhich (if available). .TP \fB\-b\fR (le|se), \fB\-\-booklet\fR (le|se) configure for printing as a booklet. Value 'le' (which is the default @@ -37,29 +49,42 @@ value when \fB\-b\fR is used with no argument) means that two-sided printing is in 'long-edge' mode (you turn from one page to the next along the long edge of the paper). 'se' is the 'short-edge' option. .TP -\fB\-c\fR, \fB\-\-clip\fR -clip pages to the computed bounding box. By default, content is not -clipped, which may result in overlap of neighbouring pages. With this -option, anything outside the bounding box will not be displayed. +\fB\-c\fR, \fB\-\-clip\fR, \fB\-nc\fR, \fB\-\-no-clip\fR +clip (or don't clip) pages to the computed bounding box. By default, +content is clipped, to avoid overlap between neighbouring pages. +With \fB--no-clip\fR, anything outside the bounding box will be +displayed. .TP \fB\-o\fR file, \fB\-\-output\fR file -name of output file; +name of output file. .TP \fB\-i\fR -ask before overwriting output file; +ask before overwriting output file. +.TP +\fB\-ow\fR +overwrite output file without asking. +.TP +\fB\-ps\fR s, \fB\-\-paper\fR s +sets paper size (default a4). The name must be known by package geometry +(more precisely, "<s>paper" should be defined in that package). .TP \fB\-fw\fR d, \fB\-\-framewidth\fR d width of the frame around each page (default 0.4pt). Set to 0pt to have no -frame at all; +frame at all. +.TP +\fB\-tf\fR [0|1], \fB\-\-tight-frame\fR [0|1] +whether the frame should be tight around the page, leaving horizontal +white space outside the frame, or should be wide and span the whole +available width. .TP \fB\-im\fR d, \fB\-\-innermargins\fR d -inner margin between frame and page (default 5pt); +inner margin between frame and page (default 5pt). .TP \fB\-m\fR d, \fB\-\-margins\fR d -margin of pages of the new document (default 5pt); +margin of pages of the new document (default 5pt). .TP \fB\-is\fR d, \fB\-\-intspaces\fR d -space between different pages (default 1pt); +space between different pages (default 1pt). .TP \fB\-p\fR list, \fB\-\-pages\fR list only consider sublist of pages of input document. List is a @@ -70,54 +95,107 @@ includes all pages. Also allows modulo, so that "\fB\-p\fR 0%2" would include only even-numbered pages. .TP \fB\-bb\fR list, \fB\-\-bb\fR list -only consider sublist of pages of input document for computing bounding box; +only consider sublist of pages of input document for computing bounding box. .TP \fB\-nobb\fR list, \fB\-\-no-bb\fR list -omit list of pages of input document from computation of bounding box; +omit list of pages of input document from computation of bounding box. .TP \fB\-g\fR, \fB\-\-get-bb\fR -only compute (and output) bounding box; +only compute (and output) bounding box. Will not produce any output file. +.TP +\fB\-kbb\fR, \fB\-\-keep-bb\fR +do not compute bounding box, preserve current margins. .TP \fB\-s\fR x y W H, \fB\-\-set-bb\fR x y W H -set the bounding box to the given values; +set the bounding box to the given values. Values are in pt; the first two +elements correspond to the lower left corner, while the last two represent +the width and height of the part to be displayed. .TP \fB\-w\fR file, \fB\-\-watermark\fR file use file as background watermark. file can be any format accepted by pdflatex (e.g. png or pdf). If file is a multipage PDF file, page n of the watermark file is used with page n of the input file, and the last -page of the watermark file is repeated if the input file has more pages; +page of the watermark file is repeated if the input file has more pages. .TP \fB\-wp\fR p, \fB\-\-watermark-period\fR p -repeat the last p pages of the watermark file instead of only the last one; +repeat the last p pages of the watermark file instead of only the last one. .TP \fB\-d\fR, \fB\-\-debug\fR -debug mode: keep intermediary files; +debug mode: keep intermediary files. .TP \fB\-V [0-3]\fR, \fB\-\-verbose\fR [0-3] -select verbosity (default: 1); +select verbosity (default: 1). .TP \fB\-q\fR, \fB\-\-quiet\fR -run quietly (equiv. '-V=0'); +run quietly (equiv. '-V 0'). .TP \fB\-v\fR, \fB\-\-version\fR -print version number and exit; +print version number and exit. .TP \fB\-h\fR, \fB\-\-help\fR print help message and exit. +.SH CONFIGURATION FILES +Configuration files (extension \fB.xup\fR) are bash scripts used +to set some variables. If option "\fB--config-file\fR <file>" +(or equivalent) is used, <file> is looked up with kpsewhich +first, if it contains no '/'. If kpsewhich does not find it, +then pdfxup checks if the file exists (using 'test -e') before +sourcing it (the \fBPATH\fR variable will not be used to find +it). + +The script should only set some internal variables of pdfxup, such as +\fBNB_ROWS\fR, \fBNB_COLUMNS\fR, \fBLANDSCAPE\fR (to set up a +predefined layout). It can be used to set the bounding box, but it is +often better to compute it on the first few pages of the document. +Here are some examples of lines that can be put in a \fB.xup\fR file: +.TP +\fBNB_COLUMNS=1\fR +set the number of columns to 1 +.TP +\fBNB_ROWS=2\fR +set the number of rows to 2 +.TP +\fBLANDSCAPE=0\fR +set portrait mode +.TP +\fBKEEP_ORIG_BBOX=1\fR +do not crop margins +.TP +\fBSET_BBOX="75 47 540 755" +set bounding box: lower left=(75,47); upper right=(540,755) +.TP +\fBTIGHT_FRAME=1\fR +set tight frames around pages +.TP +\fBINNER_MARGINS=10pt\fR +set margin around each page (inside the frame) to 10pt +.TP +\fBINTERM_SPACES=10pt\fR +set space between pages to 10pt +.TP +\fBFRAME_WIDTH=2mm\fR +set frame width to 2mm + +.PP +Other available variables can be found in the \fBsetdefaultvalues\fR function. + .SH EXAMPLES .TP \fB# pdfxup file.pdf\fR -produces 2-up pdf file from file.pdf +produces 2-up pdf file from file.pdf. .TP \fB# pdfxup -bb 1-4 file.pdf\fR same behaviour, but computes the bounding box only using the -first 4 pages (this saves time when processing long documents) +first 4 pages (this saves time when processing long documents). .TP \fB# pdfxup -b -o booklet.pdf file.pdf\fR -same behaviour, but creates a booklet (as booklet.pdf) +same behaviour, but creates a booklet (as booklet.pdf). .TP \fB# pdfxup -kbb -x1 -y2 -l0 beamer-frames.pdf\fR -arranges 2 beamer frames per page (not reducing margins) +arranges 2 beamer frames per page (not reducing margins). +.TP +\fB# pdfxup --mode beamer2 beamer-frames.pdf\fR +arranges PDF pages according to beamer2.xup configuration file. .TP \fB# pdfxup -kbb -x2 -y2 -l beamer-frames.pdf:1-12,15-19\fR arranges 4 beamer frames per page (not reducing margins), including diff --git a/Master/texmf-dist/doc/man/man1/pdfxup.man1.pdf b/Master/texmf-dist/doc/man/man1/pdfxup.man1.pdf Binary files differindex 632ec802f00..87c73a1709f 100644 --- a/Master/texmf-dist/doc/man/man1/pdfxup.man1.pdf +++ b/Master/texmf-dist/doc/man/man1/pdfxup.man1.pdf diff --git a/Master/texmf-dist/doc/support/pdfxup/README b/Master/texmf-dist/doc/support/pdfxup/README index ba3c0f05fa1..f2f7738538a 100644 --- a/Master/texmf-dist/doc/support/pdfxup/README +++ b/Master/texmf-dist/doc/support/pdfxup/README @@ -1,4 +1,4 @@ -PDFXUP -- v1.61 (2020/10/21) +PDFXUP -- v2.00 (2020/12/17) N. Markey <pdfxup@markey.fr> @@ -18,7 +18,7 @@ graphicx package) in order to produce the new document. -%% (c) 2020/10/21 Nicolas Markey <pdfxup at markey dot fr> +%% (c) 2020/12/17 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 3cd0fc61660..06f0951bc31 100644 --- a/Master/texmf-dist/doc/support/pdfxup/RELEASES +++ b/Master/texmf-dist/doc/support/pdfxup/RELEASES @@ -37,4 +37,17 @@ v1.60 (2020/06/27) v1.61 (2020/10/21) - minor bug corrected (would not clean-up with option -g) - (thanks to Oliver Redner for pointing out the bug)
\ No newline at end of file + (thanks to Oliver Redner for pointing out the bug) + +v2.00 (2020/12/17) + - fixed a bug with inner margins + - fixed problem with ranges exceeding number of pages + - extracted LaTeX file from script + - added --tight-frame option: tells whether the frame should + be tight around the page (and leave horizontal white space + outside the frame), or as large as possible. + - added --config-file option: configuration files (default + extension .xup) can be used to define default values + for frequent situations. + - cleaned-up man page, adding some missing options (thanks + to Louis Gostiaux for pointing undocumented options)
\ No newline at end of file diff --git a/Master/texmf-dist/doc/support/pdfxup/pdfxup.pdf b/Master/texmf-dist/doc/support/pdfxup/pdfxup.pdf Binary files differindex 651c92495f8..b6e779cb307 100644 --- a/Master/texmf-dist/doc/support/pdfxup/pdfxup.pdf +++ b/Master/texmf-dist/doc/support/pdfxup/pdfxup.pdf diff --git a/Master/texmf-dist/scripts/pdfxup/pdfxup b/Master/texmf-dist/scripts/pdfxup/pdfxup index 52baf20ddc2..12ac684ede8 100755 --- a/Master/texmf-dist/scripts/pdfxup/pdfxup +++ b/Master/texmf-dist/scripts/pdfxup/pdfxup @@ -2,11 +2,28 @@ shopt -s extglob shopt -s lastpipe -VERSION="1.61" -VDATE="2020/10/21" +VERSION="2.00" +VDATE="2020/12/17" ## see release notes at the end of this file. +## (c) 2020/12/17 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 +## or (at your option) any later version. The latest version of this +## license is in +## +## http://www.latex-project.org/lppl.txt +## +## and version 1.3 or later is part of all distributions of LaTeX version +## 2005/12/01 or later. +## +## This work has the LPPL maintenance status `maintained'. +## The Current Maintainer of this work is Nicolas Markey. + + + ## Roadmap ## 1) definition of some functions: ## defaultvalues() and setdefaultvalues() @@ -14,6 +31,7 @@ VDATE="2020/10/21" ## myecho() ## dimtopt() and testdim() ## ifinrangelist() +## setconfigfile() [look for configuration file] ## cleancslor() [clean comma-sep. list of ranges] ## cleanup ## 2) script: @@ -37,74 +55,95 @@ VDATE="2020/10/21" ## (might be useful for defining derived scripts) function defaultvalues() { - : ${dfpdfxupCOLS=2} - : ${dfpdfxupROWS=1} - : ${dfpdfxupLANDSC=1} - : ${dfpdfxupPAP="a4"} + : ${dfpdfxupNB_COLUMNS=2} + : ${dfpdfxupNB_ROWS=1} + : ${dfpdfxupLANDSCAPE=1} + : ${dfpdfxupPAPERSIZE="a4"} : ${dfpdfxupBOOKLET=0} : ${dfpdfxupCLIP=1} - : ${dfpdfxupOUTF="pdfxup.pdf"} - : ${dfpdfxupIHM="5pt"} - : ${dfpdfxupIVM="5pt"} - : ${dfpdfxupIM="5pt"} - : ${dfpdfxupHM="5pt"} - : ${dfpdfxupVM="5pt"} - : ${dfpdfxupM="5pt"} - : ${dfpdfxupIHS="1pt"} - : ${dfpdfxupIVS="1pt"} - : ${dfpdfxupIS="1pt"} - : ${dfpdfxupFW=".4pt"} + : ${dfpdfxupOUTPUTFILE="pdfxup.pdf"} + : ${dfpdfxupINNER_HMARGIN="5pt"} + : ${dfpdfxupINNER_VMARGIN="5pt"} + : ${dfpdfxupINNER_MARGINS="5pt"} + : ${dfpdfxupHMARGIN="5pt"} + : ${dfpdfxupVMARGIN="5pt"} + : ${dfpdfxupMARGINS="5pt"} + : ${dfpdfxupINTERM_HSPACE="1pt"} + : ${dfpdfxupINTERM_VSPACE="1pt"} + : ${dfpdfxupINTERM_SPACES="1pt"} + : ${dfpdfxupFRAME_WIDTH=".4pt"} : ${dfpdfxupPAGES="-"} - : ${dfpdfxupBB="-"} - : ${dfpdfxupNOBB=""} - : ${dfpdfxupKBB="0"} - : ${dfpdfxupGBB="0"} - : ${dfpdfxupVERB="1"} + : ${dfpdfxupINCLUDE_FOR_BBOX="-"} + : ${dfpdfxupEXCLUDE_FOR_BBOX=""} + : ${dfpdfxupKEEP_ORIG_BBOX="0"} + : ${dfpdfxupCOMPUTE_BBOX_ONLY="0"} + : ${dfpdfxupVERBOSITY="1"} : ${dfpdfxupDEBUG="0"} - : ${dfpdfxupWMPERIOD="1"} - : ${dfpdfxupALLOWOW="0"} - : ${dfpdfxupFORCEBB=""} + : ${dfpdfxupWATERMARK_PERIOD="1"} + : ${dfpdfxupSILENTLY_OVERWRITE="0"} + : ${dfpdfxupSET_BBOX=""} + : ${dfpdfxupTIGHT_FRAME="0"} } function setdefaultvalues() { - COLS=$dfpdfxupCOLS; - ROWS=$dfpdfxupROWS; - LANDSC=$dfpdfxupLANDSC; + # number of columns + NB_COLUMNS=$dfpdfxupNB_COLUMNS; + # number of rows + NB_ROWS=$dfpdfxupNB_ROWS; + # landscape mode (1=landscape, 0=portrait) + LANDSCAPE=$dfpdfxupLANDSCAPE; + # booklet mode ('se'=booklet 'short-edge', 'le'=booklet 'long-edge') BOOKLET=$dfpdfxupBOOKLET; + # clip pages to bounding box (1=yes, 0=no) CLIP=$dfpdfxupCLIP; - PAP=$dfpdfxupPAP; - OUTF=$dfpdfxupOUTF - IHM=$dfpdfxupIHM; - IVM=$dfpdfxupIVM; - IM=$dfpdfxupIM; - HM=$dfpdfxupHM; - VM=$dfpdfxupVM; - M=$dfpdfxupM; - IHS=$dfpdfxupIHS; - IVS=$dfpdfxupIVS; - IS=$dfpdfxupIS; - FW=$dfpdfxupFW; - ## don't overwrite VERB if set on command line - : ${VERB=$dfpdfxupVERB}; + # papersize ('a4', 'letter', ...) + PAPERSIZE=$dfpdfxupPAPERSIZE; + # name of output file + OUTPUTFILE=$dfpdfxupOUTPUTFILE + # (minimal) inner horizontal margin (between frame and logical page) + INNER_HMARGIN=$dfpdfxupINNER_HMARGIN; + # (minimal) inner vertical margin (between frame and logical page) + INNER_VMARGIN=$dfpdfxupINNER_VMARGIN; + # (minimal) inner margin (both horizontal and vertical) + INNER_MARGINS=$dfpdfxupINNER_MARGINS; + # horizontal margin (between content and border of physical page) + HMARGIN=$dfpdfxupHMARGIN; + # vertical margin (between content and border of physical page) + VMARGIN=$dfpdfxupVMARGIN; + # margin (between content and border of physical page) + MARGINS=$dfpdfxupMARGINS; + # intermediate horizontal space (between logical pages) + INTERM_HSPACE=$dfpdfxupINTERM_HSPACE; + # intermediate vertical space (between logical pages) + INTERM_VSPACE=$dfpdfxupINTERM_VSPACE; + # intermediate space (between logical pages) + INTERM_SPACES=$dfpdfxupINTERM_SPACES; + # frame width + FRAME_WIDTH=$dfpdfxupFRAME_WIDTH; + # verbosity level + ## don't overwrite VERBOSITY if set on command line + : ${VERBOSITY=$dfpdfxupVERBOSITY}; + # debug mode DEBUG=$dfpdfxupDEBUG; - WATERMARK=""; - WATERMARKPERIOD=$dfpdfxupWMPERIOD; - KBB=$dfpdfxupKBB; - GBB=$dfpdfxupGBB; - ALLOWOVERWRITE=$dfpdfxupALLOWOW; - SBB=0; - x0=-1 - y0=-1 - h0=-1 - w0=-1 - if [[ "$dfpdfxupFORCEBB" ]]; then - SBB=1; - read -r x0 y0 h0 w0 <<<$(echo $dfpdfxupFORCEBB); - fi + # file used for watermarking + WATERMARK_FILE=""; + # number of pages to repeat when watermarking + WATERMARK_PERIOD=$dfpdfxupWATERMARK_PERIOD; + # keep original bounding box (hence do not recompute) + KEEP_ORIG_BBOX=$dfpdfxupKEEP_ORIG_BBOX; + # only compute bounding box (hence do not produce PDF output) + COMPUTE_BBOX_ONLY=$dfpdfxupCOMPUTE_BBOX_ONLY; + # overwrite output file without warning + SILENTLY_OVERWRITE=$dfpdfxupSILENTLY_OVERWRITE; + # make frame tight around logical pages + TIGHT_FRAME=$dfpdfxupTIGHT_FRAME; + # initial bounding box + SET_BBOX=$dfpdfxupSET_BBOX + ## Notice: the names for h and w should actually be X and Y: ## they are not width and height, but coordinates of upper right corner. - ## Notice: PAGES, BB and NOBB will be set to default values if empty after + ## Notice: PAGES, INCLUDE_FOR_BBOX and EXCLUDE_FOR_BBOX will be set to default values if empty after ## processing options } @@ -117,54 +156,57 @@ function usage() if [[ "$dfpdfxupPAGES" == "-" ]]; then explicitPAGES=" (all)"; fi - if [[ "$dfpdfxupNOBB" == "" ]]; then - explicitNOBB=" (none)"; + if [[ "$dfpdfxupEXCLUDE_FOR_BBOX" == "" ]]; then + explicitEXCLUDE_FOR_BBOX=" (none)"; fi - if [[ "$dfpdfxupBB" == "-" ]]; then + if [[ "$dfpdfxupINCLUDE_FOR_BBOX" == "-" ]]; then explicitBB=" (all)"; fi - if [[ "$dfpdfxupFORCEBB" == "" ]]; then - explicitFORCEBB=" (unset)"; + if [[ "$dfpdfxupSET_BBOX" == "" ]]; then + explicitSET_BBOX=" (unset)"; fi echo "pdfxup: n-up pages of a PDF document, preserving readability usage: `basename $0` [OPTIONS] file -Available OPTIONS are: - -x n n columns per page [default: \"$dfpdfxupCOLS\"] - -y n n lines per page [default: \"$dfpdfxupROWS\"] - -l [0|1] landscape-mode [default: \"$dfpdfxupLANDSC\"] +The main OPTIONS are: + -x n n columns per page [default: \"$dfpdfxupNB_COLUMNS\"] + -y n n lines per page [default: \"$dfpdfxupNB_ROWS\"] + -l [0|1] landscape-mode [default: \"$dfpdfxupLANDSCAPE\"] -b [0|1|le|se] booklet-mode [default: \"$dfpdfxupBOOKLET\"] - -c [0|1] clip pages to bounding box [default: \"$dfpdfxupCLIP\"] - -im n inner margins [default: \"$dfpdfxupIM\"] - -m n margins [default: \"$dfpdfxupM\"] - -is n interm. spaces [default: \"$dfpdfxupIS\"] - -fw n frame width [default: \"$dfpdfxupFW\"] - -o file write output to file [default: \"$dfpdfxupOUTF\"] + -cf file import config. parameters from file [default: none] + -m n margins [default: \"$dfpdfxupMARGINS\"] + -fw n frame width [default: \"$dfpdfxupFRAME_WIDTH\"] + -o file write output to file [default: \"$dfpdfxupOUTPUTFILE\"] -p pages only include these pages [default: \"$dfpdfxupPAGES\"$explicitPAGES] - -nobb pages pages to omit when computing b.box [default: \"$dfpdfxupNOBB\"$explicitNOBB] - -bb pages pages to use for computing b.box [default: \"$dfpdfxupBB\"$explicitBB] - -g [0|1] only computes bounding box [default: \"$dfpdfxupGBB\"] - -s x y X Y force bounding box [default: \"$dfpdfxupFORCEBB\"$explicitFORCEBB] - -V [0-3] select verbosity [default: \"$dfpdfxupVERB\"] + -nobb pages pages to omit when computing b.box [default: \"$dfpdfxupEXCLUDE_FOR_BBOX\"$explicitEXCLUDE_FOR_BBOX] + -bb pages pages to use for computing b.box [default: \"$dfpdfxupINCLUDE_FOR_BBOX\"$explicitBB] + -g [0|1] only computes bounding box [default: \"$dfpdfxupCOMPUTE_BBOX_ONLY\"] + -s x y X Y force bounding box [default: \"$dfpdfxupSET_BBOX\"$explicitSET_BBOX] -w file add watermarking [default: none] - -wp n repeat last n pages of watermark file [default: \"$dfpdfxupWMPERIOD\"] + -wp n repeat last n pages of watermark file [default: \"$dfpdfxupWATERMARK_PERIOD\"] -i ask before overwriting/removing files -d debug mode: keep intermediary files - -v show version number and exit"; + -v show version number and exit +See the manual page ('man pdfxup') for the list of all options."; ## ## Some options are not presented, for the sake of brevity... ## -## -ihm n inner horizontal margin [default: \"$dfpdfxupIHM\"] -## -ivm n inner vertical margin [default: \"$dfpdfxupIVM\"] -## -hm n horizontal margin [default: \"$dfpdfxupHM\"] -## -vm n vertical margin [default: \"$dfpdfxupVM\"] -## -ihs n interm. horizontal space [detault: \"$dfpdfxupIHS\"] -## -ivs n interm. vertical space [detault: \"$dfpdfxupIVS\"] -## -kbb keep original bounding box [default: \"$dfpdfxupKBB\"] -## -ow allow overwriting [default: \"$dfpdfxupALLOWOW\"] -## -ps s output paper size [default: \"$dfpdfxupPAP\"] +## -c [0|1] clip pages to bounding box [default: \"$dfpdfxupCLIP\"] +## -im n inner margins [default: \"$dfpdfxupINNER_MARGINS\"] +## -ihm n inner horizontal margin [default: \"$dfpdfxupINNER_HMARGIN\"] +## -ivm n inner vertical margin [default: \"$dfpdfxupINNER_VMARGIN\"] +## -hm n horizontal margin [default: \"$dfpdfxupHMARGIN\"] +## -vm n vertical margin [default: \"$dfpdfxupVMARGIN\"] +## -ihs n interm. horizontal space [detault: \"$dfpdfxupINTERM_HSPACE\"] +## -ivs n interm. vertical space [detault: \"$dfpdfxupINTERM_VSPACE\"] +## -is n interm. spaces [default: \"$dfpdfxupINTERM_SPACES\"] +## -kbb keep original bounding box [default: \"$dfpdfxupKEEP_ORIG_BBOX\"] +## -ow allow overwriting [default: \"$dfpdfxupSILENTLY_OVERWRITE\"] +## -ps s output paper size [default: \"$dfpdfxupPAPERSIZE\"] +## -tf draw tight frame around each page [default: \"$dfpdfxupTIGHT_FRAME\"] ## -q run quietly (equiv. '-V=0') ## -h show this help message +## -V [0-3] select verbosity [default: \"$dfpdfxupVERBOSITY\"] ## ## ## @@ -180,13 +222,13 @@ function myecho() ECHO=0; case $1 in +([0-9])\+) - if [[ $VERB -ge ${1%+} ]]; then ECHO=1; fi + if [[ $VERBOSITY -ge ${1%+} ]]; then ECHO=1; fi ;; +([0-9])) - if [[ $VERB -eq $1 ]]; then ECHO=1; fi + if [[ $VERBOSITY -eq $1 ]]; then ECHO=1; fi ;; +([0-9])-) - if [[ $VERB -le ${1%-} ]]; then ECHO=1; fi + if [[ $VERBOSITY -le ${1%-} ]]; then ECHO=1; fi ;; esac if [[ $ECHO == 1 ]]; then @@ -294,6 +336,28 @@ function ifinrangelist() return; } +## look for config file +function setconfigfile() +{ + if [[ `echo "$1"|grep -v "/"` ]]; then + if [[ `echo "$1"|grep "\.xup$"` && $KPSEWHICH ]]; then + CFFILE=`$KPSEWHICH $1` + else + CFFILE=`$KPSEWHICH $1.xup` + fi + fi + if [[ (! -e $CFFILE) ]]; then + if [[ -e $1 ]]; then + CFFILE=$1 + else + if [[ -e $1.xup ]]; then + CFFILE=$1.xup + fi + fi + fi + #echo $CFFILE; +} + ## normalize list + count number of pages to be displayed function cleancslor() { @@ -302,17 +366,46 @@ function cleancslor() for i in ${list//,/$IFS}; do case $i in +([0-9])) - result+="$i,"; - nbpages+=1;; + if [[ $i -le $nbp ]]; then + result+="$i,"; + nbpages+=1; + else + myecho 1+ " $file has $nbp page(s); page $i does not exist." + fi + ;; -+([0-9])) - result+="1$i,"; - nbpages+=${i#-};; + if [[ $i -le $nbp ]]; then + result+="1$i,"; + nbpages+=${i#-}; + else + myecho 1+ " $file has $nbp page(s); changed 1$i to 1-$nbp." + result+="1$nbp,"; + nbpages+=${nbp#-}; + fi + ;; +([0-9])-) - result+="$i$nbp,"; - nbpages+=$(expr $nbp + 1 - ${i%-});; - +([0-9])-+([0-9])) - result+="$i,"; - nbpages+=$(expr 1 + `echo $i|cut -d- -f2` - `echo $i|cut -d- -f1`);; + if [[ $i -le $nbp ]]; then + result+="$i$nbp,"; + nbpages+=$(expr $nbp + 1 - ${i%-}); + else + myecho 1+ " $file has $nbp page(s); pages $i do not exist." + fi + ;; + +([0-9])-+([0-9])) + fstp=`echo $i|cut -d- -f1` + if [[ $fstp -gt $nbp ]]; then + myecho 1+ " $file has $nbp page(s); range $i omitted." + fi + lstp=`echo $i|cut -d- -f2` + if [[ $lstp -gt $nbp ]]; then + myecho 1+ " $file has $nbp page(s); range $i changed to $fstp-$nbp." + lstp=$nbp; + fi + if [[ $lstp -ge $fstp ]]; then + result+="$fstp-$lstp,"; + nbpages+=$(expr 1 + $lstp - $fstp) + fi + ;; -) result+="1-$nbp,"; nbpages+=$nbp;; @@ -380,7 +473,8 @@ if [ ! "$PDFLATEXVERSION" ]; then exit 1; fi - +## KPSEWHICH could be specified on command-line +: ${KPSEWHICH=`which kpsewhich`} ###################################################################### @@ -391,33 +485,41 @@ fi while [ $# != 0 ]; do case $1 in -x|--columns) - COLS=$2; + NB_COLUMNS=$2; shift 2;; -x?(=)+([0-9])) - COLS=`echo $1|sed -re "s/-x=?//"`; + NB_COLUMNS=`echo $1|sed -re "s/-x=?//"`; shift;; -y|--rows) - ROWS=$2; + NB_ROWS=$2; shift 2;; -y?(=)+([0-9])) - ROWS=`echo $1|sed -re "s/-y=?//"`; + NB_ROWS=`echo $1|sed -re "s/-y=?//"`; + shift;; + -nup|--nup) + NB_COLUMNS=`echo $2|sed -re "s/x.*$//"`; + NB_ROWS=`echo $2|sed -re "s/^.*x//"`; + shift 2;; + -?(-)nup?(=)+([0-9])x+([0-9])) + NB_COLUMNS=`echo $1|sed -re "s/x.*$//"|sed -re "s/--?nup=?//"`; + NB_ROWS=`echo $1|sed -re "s/^--?nup.*x//"`; shift;; -l|--landscape) case $2 in 1|yes|y|true) - LANDSC=1; + LANDSCAPE=1; SHIFT=2; ;; 0|no|n|false) - LANDSC=0; + LANDSCAPE=0; SHIFT=2; ;; -*) - LANDSC=1; + LANDSCAPE=1; SHIFT=1; ;; *) - LANDSC=1; + LANDSCAPE=1; #echo "Normal use of '$1' option is: '$1 [0|1]'"; #echo "Assuming you want landscape outupt..."; SHIFT=1; @@ -427,19 +529,19 @@ while [ $# != 0 ]; do ANS=`echo $1|sed -re "s/-l=?//"`; case $ANS in 1|yes|y|true) - LANDSC=1; + LANDSCAPE=1; ;; 0|no|n|false) - LANDSC=0; + LANDSCAPE=0; ;; *) - LANDSC=1; + LANDSCAPE=1; #echo "Normal use of '$1' option is: '$1 [0|1]'"; #echo "Assuming you want landscape outupt..."; esac shift;; -nl|--portrait|--no-landscape|--nolandscape) - LANDSC=0; + LANDSCAPE=0; shift;; -b|--booklet) case $2 in @@ -466,7 +568,7 @@ while [ $# != 0 ]; do SHIFT=1; esac if [[ $BOOKLET != 0 ]]; then - FW=0pt + FRAME_WIDTH=0pt # this is the default, but can be changed by passing -fw option fi shift $SHIFT;; @@ -488,10 +590,36 @@ while [ $# != 0 ]; do #echo "Assuming you want booklet outupt..."; esac if [[ $BOOKLET != 0 ]]; then - FW=0pt + FRAME_WIDTH=0pt # this is the default, but can be changed by passing -fw option fi shift;; + -cf|--config|--config-file|-?(-)mode) + case $2 in + -*) + echo "Error. Option '$1' expects a file name; found '$2'."; + echo "Aborting."; + exit 0; + ;; + *) + setconfigfile $2 + ;; + esac + if [[ -e "$CFFILE" ]]; then + source $CFFILE + else + myecho 0+ " /!\ configuration file $2 not found" + fi + shift 2;; + -cf=*|--config=*|--config-file=*|-?(-)mode=*) + TMP=`echo $1|cut -d= -f2-` + setconfigfile $TMP + if [[ -e "$CFFILE" ]]; then + source $CFFILE + else + myecho 0+ " /!\ configuration file $TMP not found" + fi + shift;; -c|--clip) case $2 in 1|yes|y|true) @@ -518,161 +646,218 @@ while [ $# != 0 ]; do ;; esac shift;; - -ps|--paper|--paper-size) - PAP=$2; + -nc|--no-clip) + CLIP=0; + shift;; + -ps|--paper|--paper?(-)size) + PAPERSIZE=$2; shift 2;; - -ps=*|--paper=*|--paper-size=*) + -ps=*|--paper=*|--paper?(-)size=*) ## '=' is compulsory, as we expect a string... - ANS=`echo $1|sed -re "s/(-ps=|--paper=|--paper-size=)//"`; - PAP=$ANS; + ANS=`echo $1|sed -re "s/(-ps=|--paper=|--paper-?size=)//"`; + PAPERSIZE=$ANS; shift;; - -p|--pages|--page) - PAGES+="$2,"; + -p|--pages|--page) + case $2 in + -) + PAGES+="$2,"; + ;; + -*) + echo "Error: option '$1' expects a range, not '$2'."; + echo "Aborting."; + exit 0; + ;; + *) + PAGES+="$2,"; + ;; + esac shift 2;; -p*|--page*) ANS=`echo $1|sed -re "s/--?p(ages?)?=?//"`; PAGES=+="$ANS,"; shift;; -o|--out|--output-file|--outfile) - OUTF=$2; + OUTPUTFILE=$2; shift 2;; -o=*|--out=*|--output-file=*|--outfile=*) ANS=`echo $1|sed -re "s/--?o(ut(put-)?(file)?)?=//"`; - OUTF=$ANS; + OUTPUTFILE=$ANS; shift;; -ow) - ALLOWOVERWRITE="1"; + SILENTLY_OVERWRITE="1"; shift;; -ihm|--innerhmargin) - dimtopt $2 $dfpdfxupIHM "$1 $2"; - IHM=$dim; + dimtopt $2 $dfpdfxupINNER_HMARGIN "$1 $2"; + INNER_HMARGIN=$dim; shift 2;; -ihm?(=)+([0-9])*) ANS=`echo $1|sed -re "s/-ihm=?//"`; - dimtopt $ANS $dfpdfxupIHM $1; - IHM=$dim; + dimtopt $ANS $dfpdfxupINNER_HMARGIN $1; + INNER_HMARGIN=$dim; shift;; -ivm|--innervmargin) - dimtopt $2 $dfpdfxupIVM "$1 $2"; - IVM=$dim; + dimtopt $2 $dfpdfxupINNER_VMARGIN "$1 $2"; + INNER_VMARGIN=$dim; shift 2;; -ivm?(=)+([0-9])*) ANS=`echo $1|sed -re "s/-ivm=?//"`; - dimtopt $ANS $dfpdfxupIVM $1; - IVM=$dim; + dimtopt $ANS $dfpdfxupINNER_VMARGIN $1; + INNER_VMARGIN=$dim; shift;; -im|--innermargins) - dimtopt $2 $dfpdfxupIM "$1 $2"; - IHM=$dim; - IVM=$dim; + dimtopt $2 $dfpdfxupINNER_MARGINS "$1 $2"; + INNER_HMARGIN=$dim; + INNER_VMARGIN=$dim; shift 2;; -im?(=)+([0-9])*) ANS=`echo $1|sed -re "s/-im=?//"`; - dimtopt $ANS $dfpdfxupIM $1; - IHM=$dim; - IVM=$dim; + dimtopt $ANS $dfpdfxupINNER_MARGINS $1; + INNER_HMARGIN=$dim; + INNER_VMARGIN=$dim; shift;; -hm|--hmargin) - testdim $2 $dfpdfxupHM "$1 $2"; - HM=$dim; + testdim $2 $dfpdfxupHMARGIN "$1 $2"; + HMARGIN=$dim; shift 2;; -hm?(=)+([0-9])*) ANS=`echo $1|sed -re "s/-hm=?//"`; - testdim $ANS $dfpdfxupHM $1; - HM=$dim; + testdim $ANS $dfpdfxupHMARGIN $1; + HMARGIN=$dim; shift;; -vm|--vmargin) - testdim $2 $dfpdfxupVM "$1 $2"; - VM=$dim; + testdim $2 $dfpdfxupVMARGIN "$1 $2"; + VMARGIN=$dim; shift 2;; -vm?(=)+([0-9])*) ANS=`echo $1|sed -re "s/-vm=?//"`; - testdim $ANS $dfpdfxupVM $1; - VM=$dim; + testdim $ANS $dfpdfxupVMARGIN $1; + VMARGIN=$dim; shift;; -m|--margins) - testdim $2 $dfpdfxupM "$1 $2"; - HM=$dim; - VM=$dim; + testdim $2 $dfpdfxupMARGINS "$1 $2"; + HMARGIN=$dim; + VMARGIN=$dim; shift 2;; -m?(=)+([0-9])*) ANS=`echo $1|sed -re "s/-m=?//"`; - testdim $ANS $dfpdfxupM $1; - HM=$dim; - VM=$dim; + testdim $ANS $dfpdfxupMARGINS $1; + HMARGIN=$dim; + VMARGIN=$dim; shift;; -ihs|--inthspace) - testdim $2 $dfpdfxupIHS "$1 $2"; - IHS=$dim; + testdim $2 $dfpdfxupINTERM_HSPACE "$1 $2"; + INTERM_HSPACE=$dim; shift 2;; -ihs?(=)+([0-9])*) ANS=`echo $1|sed -re "s/-ihs=?//"`; - testdim $ANS $dfpdfxupIHS $1; - IHS=$dim; + testdim $ANS $dfpdfxupINTERM_HSPACE $1; + INTERM_HSPACE=$dim; shift;; -ivs|--intvspace) - testdim $2 $dfpdfxupIVS "$1 $2"; - IVS=$dim; + testdim $2 $dfpdfxupINTERM_VSPACE "$1 $2"; + INTERM_VSPACE=$dim; shift 2;; -ivs?(=)+([0-9])*) ANS=`echo $1|sed -re "s/-ivs=?//"`; - testdim $ANS $dfpdfxupIVS $1; - IVS=$dim; + testdim $ANS $dfpdfxupINTERM_VSPACE $1; + INTERM_VSPACE=$dim; shift;; -is|--intspaces) - testdim $2 $dfpdfxupIS "$1 $2"; - IHS=$dim; - IVS=$dim; + testdim $2 $dfpdfxupINTERM_SPACES "$1 $2"; + INTERM_HSPACE=$dim; + INTERM_VSPACE=$dim; shift 2;; -is?(=)+([0-9])*) ANS=`echo $1|sed -re "s/-is=?//"`; - testdim $ANS $dfpdfxupIS $1; - IHS=$dim; - IVS=$dim; + testdim $ANS $dfpdfxupINTERM_SPACES $1; + INTERM_HSPACE=$dim; + INTERM_VSPACE=$dim; shift;; - -fw|--framewidth) - testdim $2 $dfpdfxupFW "$1 $2"; - FW=$dim; + -fw|--framewidth|--frame-width) + testdim $2 $dfpdfxupFRAME_WIDTH "$1 $2"; + FRAME_WIDTH=$dim; shift 2;; -fw?(=)+([0-9])*) ANS=`echo $1|sed -re "s/-fw=?//"`; - testdim $ANS $dfpdfxupFW $1; - FW=$dim; + testdim $ANS $dfpdfxupFRAME_WIDTH $1; + FRAME_WIDTH=$dim; + shift;; + -tf|--tight-frame) + case $2 in + 1|yes|y|true) + TIGHT_FRAME=1; + SHIFT=1; + ;; + 0|no|n|false) + TIGHT_FRAME=0; + SHIFT=1; + ;; + *) + TIGHT_FRAME=1; + SHIFT=1; + esac + shift $SHIFT;; + -tf*|--tight-frame*) + TIGHT_FRAME=`echo $1|sed -re "s/--?t(ight-)?f(rame)?=?//"`; shift;; -i) MVopt="-i"; RMopt="-i"; shift;; -nobb|--nobb|-no-bb|--no-bb) - NOBB+="$2,"; + case $2 in + -) + EXCLUDE_FOR_BBOX+="$2,"; + ;; + -*) + echo "Error: option '$1' expects a range, not '$2'."; + echo "Aborting."; + exit 0; + ;; + *) + EXCLUDE_FOR_BBOX+="$2,"; + ;; + esac shift 2;; -nobb*|--no-bb*) ANS=`echo $1|sed -re "s/--?no-?bb=?//"`; - NOBB+="$ANS,"; + EXCLUDE_FOR_BBOX+="$ANS,"; shift;; -bb|--bb|--bounding-box) - BB+="$2,"; + case $2 in + -) + INCLUDE_FOR_BBOX+="$2,"; + ;; + -*) + echo "Error: option '$1' expects a range, 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)?=?//"`; - BB+="$ANS,"; + INCLUDE_FOR_BBOX+="$ANS,"; shift;; -kbb|--keepbb|--keep-bb|--original-bb) case $2 in 1|yes|y|true) - KBB=1; + KEEP_ORIG_BBOX=1; SHIFT=2; ;; 0|no|n|false) - KBB=0; + KEEP_ORIG_BBOX=0; SHIFT=2; ;; -*) - KBB=1; + KEEP_ORIG_BBOX=1; SHIFT=1; ;; *) - KBB=1; + KEEP_ORIG_BBOX=1; SHIFT=1; esac shift $SHIFT;; @@ -680,31 +865,31 @@ while [ $# != 0 ]; do ANS=`echo $1|sed -re "s/--?(k(eep-?)?bb|orig[^=]*bb)=?//"`; case $ANS in 1|yes|y|true) - KBB=1; + KEEP_ORIG_BBOX=1; ;; 0|no|n|false) - KBB=0; + KEEP_ORIG_BBOX=0; ;; *) - KBB=1; + KEEP_ORIG_BBOX=1; esac shift;; -g|--get-bb|--getbb) case $2 in 1|yes|y|true) - GBB=1; + COMPUTE_BBOX_ONLY=1; SHIFT=2; ;; 0|no|n|false) - GBB=0; + COMPUTE_BBOX_ONLY=0; SHIFT=2; ;; -*) - GBB=1; + COMPUTE_BBOX_ONLY=1; SHIFT=1; ;; *) - GBB=1; + COMPUTE_BBOX_ONLY=1; SHIFT=1; esac shift $SHIFT;; @@ -712,13 +897,13 @@ while [ $# != 0 ]; do ANS=`echo $1|sed -re "s/--?g(etbb|et-bb)?=?//"`; case $ANS in 1|yes|y|true) - GBB=1; + COMPUTE_BBOX_ONLY=1; ;; 0|no|n|false) - GBB=0; + COMPUTE_BBOX_ONLY=0; ;; *) - GBB=1; + COMPUTE_BBOX_ONLY=1; #echo "Normal use of '$1' option is: '$1 [0|1]'"; #echo "Assuming you want landscape outupt..."; esac @@ -726,61 +911,63 @@ while [ $# != 0 ]; do -s|--set-bb|--setbb) case "$2$3$4$5" in +([0-9])) - SBB=1; - BBX=$2; - BBY=$3; - BBW=$4; - BBH=$5;; + SET_BBOX="$2 $3 $4 $5" + ;; + *) + echo "Error: option '$1' expects 4 numbers."; + echo "Aborting."; + exit 0; + ;; esac shift 5;; -V) case $2 in @(0|1|2|3)) - if [[ $VERB -lt $2 ]]; then - VERB=$2; + if [[ $VERBOSITY -lt $2 ]]; then + VERBOSITY=$2; fi SHIFT=2;; *) - if [[ $VERB -lt 2 ]]; then - VERB=2; + if [[ $VERBOSITY -lt 2 ]]; then + VERBOSITY=2; fi SHIFT=1;; esac shift $SHIFT;; -V?(=)@(0|1|2|3)) - if [[ $VERB -lt `echo $1|sed -re "s/-V=?//"` ]]; then - VERB=`echo $1|sed -re "s/-V=?//"`; + if [[ $VERBOSITY -lt `echo $1|sed -re "s/-V=?//"` ]]; then + VERBOSITY=`echo $1|sed -re "s/-V=?//"`; fi shift;; -V?(=)+([0-9])) - VERB=9; + VERBOSITY=9; shift;; -VV) - if [[ $VERB -lt 3 ]]; then - VERB=3; + if [[ $VERBOSITY -lt 3 ]]; then + VERBOSITY=3; fi shift;; -VVV) - if [[ $VERB -lt 4 ]]; then - VERB=4; + if [[ $VERBOSITY -lt 4 ]]; then + VERBOSITY=4; fi shift;; -q|--quiet) - VERB=0; + VERBOSITY=0; shift;; -w|--watermark|--watermark-file) - WATERMARK=$2; + WATERMARK_FILE=$2; shift 2;; -w=*|--watermark=*|--watermark-file=*) ANS=`echo $1|sed -re "s/--?w[^=]*=//"`; - WATERMARK=$ANS; + WATERMARK_FILE=$ANS; shift;; -wp|--wperiod|--watermark-period) - WATERMARKPERIOD=$2; + WATERMARK_PERIOD=$2; shift 2;; -wp=*|--wperiod=*|--watermark-period=*) ANS=`echo $1|sed -re "s/--?w[^=]*=//"`; - WATERMARKPERIOD=$ANS; + WATERMARK_PERIOD=$ANS; shift;; -v|--version) echo "pdfxup version $VERSION (released $VDATE)"; @@ -827,63 +1014,78 @@ fi ## check output file +## set bbox +SBB=0; +read -r x0 y0 w0 h0 <<<$(echo "-1 -1 -1 -1"); +if [[ "$SET_BBOX" ]]; then + SBB=1; + read -r BBX BBY BBW BBH <<<$(echo $SET_BBOX); +fi + ## summarize options: myecho 1+ "-> processing options"; - +if [[ "$FILE" != "" ]]; then + myecho 2+ " * used configuration file $FILE"; +fi if [[ $BOOKLET -eq 1 ]]; then myecho 2+ " * booklet mode (long-edge)"; else if [[ $BOOKLET -eq 2 ]]; then myecho 2+ " * booklet mode (short edge)"; else - myecho 2+ -ne " * columns=$COLS, rows=$ROWS, "; - if [[ $LANDSC -eq 1 ]]; then + myecho 2+ -ne " * columns=$NB_COLUMNS, rows=$NB_ROWS, "; + if [[ $LANDSCAPE -eq 1 ]]; then myecho 2+ "landscape mode"; else myecho 2+ "portrait mode"; fi fi fi -myecho 2+ " * paper size=$PAP"; +myecho 2+ " * paper size=$PAPERSIZE"; if [[ $CLIP -eq 1 ]]; then myecho 2+ " * clipping content outside bounding box"; else myecho 2+ " * not clipping content outside bounding box"; fi -myecho 2+ " * output file is \"$OUTF\""; -if [[ "$IHM" == "$IVM" ]]; then - myecho 2+ " * inner margins=$IHM"; +myecho 2+ " * output file is \"$OUTPUTFILE\""; +if [[ "$INNER_HMARGIN" == "$INNER_VMARGIN" ]]; then + myecho 2+ " * inner margins=$INNER_HMARGIN"; else - myecho 2+ " * inner horizontal margin=$IHM, inner vertical margin=$IVM"; + myecho 2+ " * inner horizontal margin=$INNER_HMARGIN, inner vertical margin=$INNER_VMARGIN"; fi -if [[ "$HM" == "$VM" ]]; then - myecho 2+ " * margins=$HM"; +if [[ "$HMARGIN" == "$VMARGIN" ]]; then + myecho 2+ " * margins=$HMARGIN"; else - myecho 2+ " * horizontal margin=$HM, vertical margin=$VM"; + myecho 2+ " * horizontal margin=$HMARGIN, vertical margin=$VMARGIN"; fi -if [[ "$IHS" == "$IVS" ]]; then - myecho 2+ " * space between pages=$IHS"; +if [[ "$INTERM_HSPACE" == "$INTERM_VSPACE" ]]; then + myecho 2+ " * space between pages=$INTERM_HSPACE"; else - myecho 2+ " * horizontal space between pages=$IHS, vertical space=$IVS"; + myecho 2+ " * horizontal space between pages=$INTERM_HSPACE, vertical space=$INTERM_VSPACE"; fi -myecho 2+ " * frame rule width=$FW"; +if [[ $TIGHT_FRAME -eq 1 ]]; then + TIGHT_FRAMEMESSAGE=" (tight)"; +else + TIGHT_FRAMEMESSAGE=" (loose)"; +fi +myecho 2+ " * frame rule width=$FRAME_WIDTH $TIGHT_FRAMEMESSAGE"; if [[ $MVopt == "-i" && $RMopt == "-i" ]]; then myecho 2+ " * interactive clean up"; else myecho 2+ " * non-interactive clean up"; fi -if [[ $GBB -eq 1 ]]; then +if [[ $COMPUTE_BBOX_ONLY -eq 1 ]]; then myecho 2+ " * only compute bounding box"; fi -if [[ $KBB -eq 1 ]]; then +if [[ $KEEP_ORIG_BBOX -eq 1 ]]; then myecho 2+ " * keep original bounding box"; fi if [[ $SBB -eq 1 ]]; then - myecho 2+ " * bounding box set to $2 $3 $4 $5"; + myecho 2+ " * bounding box set to $BBX $BBY $BBW $BBH"; fi -if [[ "$WATERMARK" ]]; then - myecho 2+ " * watermarking with file $WATERMARK"; - myecho 2+ " * watermarking period=$WATERMARKPERIOD"; +if [[ "$WATERMARK_FILE" ]]; then + myecho 2+ " * watermarking with file $WATERMARK_FILE"; + myecho 2+ " * watermarking period=$WATERMARK_PERIOD"; fi @@ -912,32 +1114,31 @@ nbp=`$GS $GSOPTFILE -sDEVICE=bbox -dNOPAUSE -dQUIET -c "($inputfilename.pdf) (r) myecho 2+ " File \"$file\" has $nbp pages"; -## now we can deal with ranges of pages (BB, NOBB, PAGES) +## now we can deal with ranges of pages (INCLUDE_FOR_BBOX, EXCLUDE_FOR_BBOX, PAGES) ## cleancslor uses $nbp, so we have to compute this before declare -i nbpages; -nbpages=0; -if [[ ${BB} != "" ]]; then - BB=${BB%,}; - cleancslor $BB; - BB=${result%,}; - myecho 3+ " * use for bounding-box computation: "${BB}; +if [[ ${INCLUDE_FOR_BBOX} != "" ]]; then + INCLUDE_FOR_BBOX=${INCLUDE_FOR_BBOX%,}; + cleancslor $INCLUDE_FOR_BBOX; + INCLUDE_FOR_BBOX=${result%,}; + myecho 3+ " * use for bounding-box computation: "${INCLUDE_FOR_BBOX}; else if [[ ${PAGES} != "" ]]; then - BB=${PAGES%,}; - cleancslor $BB; - BB=${result%,}; - myecho 3+ " * use for bounding-box computation: "${BB}; + INCLUDE_FOR_BBOX=${PAGES%,}; + cleancslor $INCLUDE_FOR_BBOX; + INCLUDE_FOR_BBOX=${result%,}; + myecho 3+ " * use for bounding-box computation: "${INCLUDE_FOR_BBOX}; else - BB=$dfpdfxupBB; + INCLUDE_FOR_BBOX=$dfpdfxupINCLUDE_FOR_BBOX; fi fi -if [[ ${NOBB} != "" ]]; then - NOBB=${NOBB%,}; - cleancslor $NOBB; - NOBB=${result%,}; - myecho 3+ " * exclude from bounding-box computation: "${NOBB}; +if [[ ${EXCLUDE_FOR_BBOX} != "" ]]; then + EXCLUDE_FOR_BBOX=${EXCLUDE_FOR_BBOX%,}; + cleancslor $EXCLUDE_FOR_BBOX; + EXCLUDE_FOR_BBOX=${result%,}; + myecho 3+ " * exclude from bounding-box computation: "${EXCLUDE_FOR_BBOX}; else - NOBB=$dfpdfxupNOBB; + EXCLUDE_FOR_BBOX=$dfpdfxupEXCLUDE_FOR_BBOX; fi if [[ ${PAGES} != "" ]]; then PAGES=${PAGES%,}; @@ -947,7 +1148,11 @@ fi nbpages=0; cleancslor $PAGES; PAGES=${result%,}; -myecho 3+ " * pages to display: ${PAGES} (${nbpages} pages)"; +myecho 2+ " * pages to display: ${PAGES} (${nbpages} pages)"; +if [[ $nbpages -le 0 ]]; then + myecho 1+ " No pages to include. Aborting." + exit 0; +fi ###################################################################### ## set up some variables @@ -963,11 +1168,20 @@ else fi +## whether the frame should be tight around pages, or loose (use all width) +if [[ $TIGHT_FRAME -eq 1 ]]; then + TIGHT_FRAMEBOX="\fbox"; + WIDE_FRAMEBOX=""; +else + TIGHT_FRAMEBOX=""; + WIDE_FRAMEBOX="\fbox"; +fi + ## special case: if booklet, we force the numbers of rows and cols if [[ $BOOKLET != 0 ]]; then - if [[ $COLS != 2 || $ROWS != 1 || $LANDSC == 0 ]]; then + if [[ $NB_COLUMNS != 2 || $NB_ROWS != 1 || $LANDSCAPE == 0 ]]; then myecho 1+ " forcing booklet mode: 2 columns, 1 row, landscape mode"; - COLS=2; ROWS=1; LANDSC=1; + NB_COLUMNS=2; NB_ROWS=1; LANDSCAPE=1; fi fi @@ -975,23 +1189,23 @@ fi ## check watermarking file nbwp=1; ## set even if no watemark -if [[ $WATERMARK != "" ]]; then - if [[ ! -e $WATERMARK ]]; then +if [[ $WATERMARK_FILE != "" ]]; then + if [[ ! -e $WATERMARK_FILE ]]; then myecho 1+ " pdfxup: watermarking file not found. Omiting watermarking." else - myecho 2+ " * using file $WATERMARK for watermarking"; + myecho 2+ " * using file $WATERMARK_FILE for watermarking"; fi fi -## get number of pages of WATERMARK (PDF) file -if [[ $WATERMARK != "" ]]; then - if [[ -e $WATERMARK ]]; then - if [[ `file -b $WATERMARK | grep "PDF"` ]]; then +## get number of pages of WATERMARK_FILE (PDF) file +if [[ $WATERMARK_FILE != "" ]]; then + if [[ -e $WATERMARK_FILE ]]; then + if [[ `file -b $WATERMARK_FILE | grep "PDF"` ]]; then ## copy file in case it contains spaces - cp "$WATERMARK" $watermarkfilename.pdf + cp "$WATERMARK_FILE" $watermarkfilename.pdf nbwp=`$GS $GSOPTWATERMARK -sDEVICE=bbox -dNOPAUSE -dQUIET -c "($watermarkfilename.pdf) (r) file runpdfbegin pdfpagecount = quit"` - if [[ $WATERMARKPERIOD -gt $nbwp || $WATERMARKPERIOD -lt 1 ]]; then - WATERMARKPERIOD=$nbwp; + if [[ $WATERMARK_PERIOD -gt $nbwp || $WATERMARK_PERIOD -lt 1 ]]; then + WATERMARK_PERIOD=$nbwp; fi fi fi @@ -1009,12 +1223,13 @@ curr=0 page=0 step=0 -if [[ $KBB == 0 ]]; then + +if [[ $KEEP_ORIG_BBOX == 0 ]]; then if [[ $SBB == 0 ]]; then myecho 1+ -n "-> computing bounding box"; myecho 2+ ""; - for r in ${BB//,/$IFS}; + for r in ${INCLUDE_FOR_BBOX//,/$IFS}; do case $r in +([0-9])) @@ -1058,7 +1273,7 @@ if [[ $KBB == 0 ]]; then 3) thish=$i; #if [[ $h -lt $i ]]; then h=$i; fi - ifinrangelist $page $NOBB; + ifinrangelist $page $EXCLUDE_FOR_BBOX; if [ $in == 0 ]; then eval step=$(( step+1 )); if [[ $x -lt 0 || $x -gt $thisx && $thisx+$thisw -gt 0 ]]; then x=$thisx; fi @@ -1076,6 +1291,7 @@ if [[ $KBB == 0 ]]; then fi done; done; + myecho 2- ""; else x=$BBX; y=$BBY; @@ -1085,18 +1301,17 @@ if [[ $KBB == 0 ]]; then fi -EMPTYBB=$KBB; -if [[ $KBB == 0 && $x -eq $x0 && +EMPTYBB=$KEEP_ORIG_BBOX; +if [[ $KEEP_ORIG_BBOX == 0 && $x -eq $x0 && $y -eq $y0 && $h -eq $h0 && $w -eq $w0 ]]; then - myecho 1+ ""; myecho 1+ " * empty bounding box; keeping original margins"; EMPTYBB=1; #exit 1; fi -if [[ $SBB == 0 && $EMPTYBB == 0 ]]; then +if [[ $SINCLUDE_FOR_BBOX == 0 && $EMPTYBB == 0 ]]; then myecho 1 -n "." myecho 2+ -ne " bbox: x=$x y=$y X=$w Y=$h (final) \\r"; myecho 3+ ""; @@ -1104,7 +1319,7 @@ if [[ $SBB == 0 && $EMPTYBB == 0 ]]; then myecho 1+ ""; fi -if [[ $GBB != 0 ]]; then +if [[ $COMPUTE_BBOX_ONLY != 0 ]]; then myecho 1+ " final bounding box: x=$x y=$y X=$w Y=$h"; cleanup; exit 0; @@ -1113,16 +1328,17 @@ fi ## compute options to pass to \includegraphics -IHM=${IHM%pt}; -IVM=${IVM%pt}; +#INNER_HMARGIN=${INNER_HMARGIN%pt}; +#INNER_VMARGIN=${INNER_VMARGIN%pt}; if [[ $EMPTYBB -eq 0 ]]; then - eval x=$((x-IHM)) - eval y=$((y-IVM)) - eval w=$((w+IHM)) - eval h=$((h+IVM)) +# eval x=$((x-INNER_HMARGIN)) +# eval y=$((y-INNER_VMARGIN)) +# eval w=$((w+INNER_HMARGIN)) +# eval h=$((h+INNER_VMARGIN)) BBOPTION="viewport=$x $y $w $h"; else - BBOPTION="trim=-$IHM -$IVM -$IHM -$IVM"; +# BBOPTION="trim=-$INNER_HMARGIN -$INNER_VMARGIN -$INNER_HMARGIN -$INNER_VMARGIN"; + BBOPTION="trim=0 0 0 0"; fi ###################################################################### @@ -1144,266 +1360,43 @@ case $BOOKLET in esac cat >> $filename.tex <<EOF - \documentclass{article} - \usepackage[margin=0pt]{geometry} - \usepackage{graphicx} - \IfFileExists{grffile.sty}{\usepackage{grffile}}{} - \topskip=0pt - - \makeatletter - - %% \nthvalue#1#2 looks for #1-th value in list of intervals #2 - \newcounter{result}% - \newif\iffound - \def\@parserange#1-#2-#3\@end#4\@end{% - \setcounter{result}{#4}% - \ifnum\value{result}=1\relax - \foundtrue - \setcounter{result}{#1}% - \else - \addtocounter{result}{-1}% - \ifx\relax#3\relax%% means that range contains no - - \else - \addtocounter{result}{#1}% - \ifnum#2<\value{result}\relax - \addtocounter{result}{-#2}% - \else - \foundtrue - \fi - \fi - \fi} - \def\parserange#1#2{\expandafter\@parserange#2-SINGLE-\@end#1\@end} - \def\@parsecsl#1,#2\@end#3\@end{% - \parserange{#3}{#1}% - \iffound\else - \ifx\relax#2\relax\else\@parsecsl#2\@end\value{result}\@end\fi\fi} - \def\nthvalue#1#2{\foundfalse\expandafter\@parsecsl#2,\@end#1\@end} - %% - - \def\file{$inputfilename.pdf} - \def\pagelist{$PAGES} - \def\watermark{$WATERMARK} - \pdfximage{\file} - \parindent=0pt - - \def\outputpaper{$PAP} - \def\outputlandscape{$LANDSC} - \def\nbhoriz{$COLS} - \def\nbvert{$ROWS} - - \expandafter\geometry\expandafter{\outputpaper paper} - \ifnum\outputlandscape=1\relax\geometry{landscape}\fi - - \newcounter{outpage} - \newcounter{lastpage} - %\setcounter{outpage}{\the\pdflastximagepages} - \setcounter{outpage}{$nbpages} - \addtocounter{outpage}{-1} - \divide\c@outpage by \nbhoriz - \divide\c@outpage by \nbvert - \ifbooklet - \divide\c@outpage by 2 - \fi - \stepcounter{outpage} - \ifbooklet - \multiply\c@outpage by 2 - \fi - \setcounter{lastpage}{\value{outpage}} - \multiply\c@lastpage by \nbhoriz - \multiply\c@lastpage by \nbvert - %\showthe\c@outpage - \makeatother - % - \newlength\outputvmargin - \newlength\outputhmargin - \setlength\outputvmargin{$VM} - \setlength\outputhmargin{$HM} - \newlength\outputindivvmargin - \newlength\outputindivhmargin - \setlength\outputindivvmargin{$IVS} - \setlength\outputindivhmargin{$IHS} - % - \fboxsep=0pt% - \setlength\fboxrule{$FW} - \newlength\hresult - \newlength\vresult - \hresult=\paperwidth - \advance\hresult by -\nbhoriz\fboxrule - \advance\hresult by -\nbhoriz\fboxrule - \vresult=\paperheight - \advance\vresult by -\nbvert\fboxrule - \advance\vresult by -\nbvert\fboxrule - % - \advance\hresult by -2\outputhmargin - \advance\vresult by -2\outputvmargin - % - \advance\hresult by -\nbhoriz \outputindivhmargin - \advance\vresult by -\nbvert \outputindivvmargin - \advance\hresult by \outputindivhmargin - \advance\vresult by \outputindivvmargin - % - \divide\hresult by \nbhoriz - \divide\vresult by \nbvert - - % computing actual scale - \if0$EMPTYBB - \newcounter{origx} - \setcounter{origx}{$w} - \addtocounter{origx}{-$x} - \newcounter{origy} - \setcounter{origy}{$h} - \addtocounter{origy}{-$y} - \newlength\finalx - \newlength\finaly - \finalx=\hresult - \finaly=\vresult - \divide\finalx by \value{origx} - \divide\finaly by \value{origy} - \newwrite\scale - \immediate\openout\scale=$filename.scl - \ifdim\finalx>\finaly - \multiply\finaly by 100 - \immediate\write\scale{\the\finaly} - \else - \multiply\finalx by 100 - \immediate\write\scale{\the\finalx} - \fi - \immediate\closeout\scale - \fi - - \begin{document} - %\tracingoutput=1 - %\tracingpages=1 - %\tracingparagraphs=1 - \makeatletter - \newcounter{curroutpage} - \setcounter{curroutpage}{1} - \addtocounter{curroutpage}{-1} - \newcounter{currpage} - \newcounter{currcol} - \newcounter{currline} - \newcounter{realout} - \newcounter{wmout} - \newcounter{wmoutaux} - %\showthe\value{outpage} - %\showthe\value{curroutpage} - \@whilenum \value{outpage}>\value{curroutpage} \do% - {\stepcounter{curroutpage}% - \setcounter{currpage}{\value{curroutpage}}% - \advance\c@currpage by -1% - \multiply\c@currpage by \nbhoriz% - \multiply\c@currpage by \nbvert% - \hrule \@height\z@% - \setcounter{currline}{0}% - \vskip \outputvmargin% - \@whilenum\value{currline}<\nbvert \do% - {\hrule \@height\z@\vskip \outputindivvmargin% - \ifnum\value{currline}>0\vskip \outputindivvmargin\fi% - \global\stepcounter{currline}% - \setcounter{currcol}{0}% - \hskip \outputhmargin% - \@whilenum\value{currcol}<\nbhoriz \do% - {\ifnum\value{currcol}>0\hskip\outputindivhmargin\fi% - \global\stepcounter{currcol}% - \global\stepcounter{currpage}% - \ifnum\value{currpage}>\value{lastpage}\else - %% computing page number corresponding to \currline and \currcol - \setcounter{realout}{\value{currpage}}% - \def\ang{0}% - \ifbooklet - \iflongedge - %% long edge: - %% 1->n, 2->1, 3->n-1 (rotated), 4->2(rotated)... - \ifodd\value{realout}% -> 1 or 3 - \addtocounter{realout}{-1}% - \divide\c@realout by 2\relax - \ifodd\value{realout}% -> 3 - \def\ang{180}% - \else% -> 1 - \fi - \setcounter{realout}{-\value{realout}}% - \addtocounter{realout}{\value{outpage}}% - \addtocounter{realout}{\value{outpage}}% - \else% -> 2 or 4 - \divide\c@realout by 2\relax - \ifodd\value{realout}% -> 2 - \else% -> 4 - \def\ang{180}% - \fi - \fi - \else - %% short edge: - %% 1->n, 2->1, 3->2, 4->n-1, 5->n-2, 6->3, 7->4, 8->n-3 - \ifodd\value{realout}% -> 1 or 3 - \addtocounter{realout}{-1}% - \divide\c@realout by 2\relax - \ifodd\value{realout}% -> 3 - \stepcounter{realout} - \else% -> 1 - \setcounter{realout}{-\value{realout}}% - \addtocounter{realout}{\value{outpage}}% - \addtocounter{realout}{\value{outpage}}% - \fi - \else% -> 2 or 4 - \divide\c@realout by 2\relax - \ifodd\value{realout}% -> 2 - \else% -> 4 - \setcounter{realout}{-\value{realout}}% - \stepcounter{realout} - \addtocounter{realout}{\value{outpage}}% - \addtocounter{realout}{\value{outpage}}% - \fi - \fi - \fi - \fi - \ifnum\value{realout}>$nbpages\relax - %% if page above nb of pages, output blank page - \hskip\hresult\hskip2\fboxrule - \else - %% otherwise compute corresponding page to display - %% first keep realout for watermarking... - \setcounter{wmoutaux}{\value{realout}}% - \setcounter{wmout}{\value{realout}}% - \nthvalue{\value{realout}}{\pagelist}% - \iffound\setcounter{realout}{\value{result}}% - \else %% hmmm... problem - \message{I'm messed up counting pages...}% - \fi - %% compute watermarking page (should be original realout?) - \ifx\watermark\@empty\else - \ifnum$nbwp<\value{wmoutaux}\relax - \addtocounter{wmoutaux}{-$nbwp}% - \addtocounter{wmoutaux}{-1}% - \divide\c@wmoutaux by $WATERMARKPERIOD\relax - \stepcounter{wmoutaux}% - \multiply\c@wmoutaux by $WATERMARKPERIOD\relax - \addtocounter{wmout}{-\value{wmoutaux}}% - \fi - \vbox to \vresult{\vfill - \hbox to \hresult{\hfill - \includegraphics[keepaspectratio,% - height=\vresult,width=\hresult,angle=\ang,% - page=\value{wmout}$CLIPOPT]{$WATERMARK}\hfill}\vfill}% - \hskip-\hresult\relax - \fi - \fbox{\vbox to \vresult{\vfill - \hbox to \hresult{\hfill - \includegraphics[$BBOPTION,% - keepaspectratio,height=\vresult,width=\hresult,angle=\ang,% - page=\value{realout}$CLIPOPT]{\file}\hfill}\vfill}}% - \fi - \fi}}% - \clearpage% - }% - \makeatother% - \end{document} + \def\pdfxupfile{$inputfilename.pdf} + \def\pdfxuppagelist{$PAGES} + \def\pdfxupoutputpaper{$PAPERSIZE} + \def\pdfxupoutputlandscape{$LANDSCAPE} + \def\pdfxupnbhoriz{$NB_COLUMNS} + \def\pdfxupnbvert{$NB_ROWS} + \def\pdfxupnbpages{$nbpages} + \def\pdfxupvmargin{$VMARGIN} + \def\pdfxuphmargin{$HMARGIN} + \def\pdfxupinnervmargin{$INNER_VMARGIN} + \def\pdfxupinnerhmargin{$INNER_HMARGIN} + \def\pdfxupintermvspace{$INTERM_VSPACE} + \def\pdfxupintermhspace{$INTERM_HSPACE} + \def\pdfxupframewidth{$FRAME_WIDTH} + \def\pdfxupemptybb{$EMPTYBB} + \def\pdfxupx{$x} + \def\pdfxupy{$y} + \def\pdfxupw{$w} + \def\pdfxuph{$h} + \def\pdfxupfilename{$filename} + \def\pdfxupwatermark{$WATERMARK_FILE} + \def\pdfxupnbwp{$nbwp} + \def\pdfxupwperiod{$WATERMARK_PERIOD} + \def\pdfxupclipopt{$CLIPOPT} + \def\pdfxupwidefbox{$WIDE_FRAMEBOX} + \def\pdfxuptightfbox{$TIGHT_FRAMEBOX} + \def\pdfxupbbox{$BBOPTION} + + \input{pdfxup-template} + EOF ###################################################################### ## produce PDF output ###################################################################### myecho 1+ "-> producing final file"; -case $VERB in +case $VERBOSITY in 0|1|2) myecho 2+ " * $PDFLATEX -interaction=nonstopmode $filename.tex" $PDFLATEX -interaction=batchmode $filename.tex > /dev/null 2>&1 || \ @@ -1417,19 +1410,20 @@ esac ## clean up ###################################################################### if [[ $LATEXFAILED -eq 1 ]]; then - myecho 1+ ": failed!" + myecho 1+ "$PDFLATEX: compilation failed!" + myecho 1+ "Use option '-d' to get and analyse failing file." cleanup exit 0; fi if [[ $EMPTYBB -eq 0 ]]; then - myecho 1+ " final scale: "`cat $filename.scl | sed -e "s/pt$//"`"%" + myecho 0+ " final scale: "`cat $filename.scl | sed -e "s/pt$//"`"%" fi -if [[ $ALLOWOVERWRITE -eq 1 ]]; then - myecho 2+ " * mv $MVopt $filename.pdf \"$OUTF\"" - mv $MVopt $filename.pdf "$OUTF" +if [[ $SILENTLY_OVERWRITE -eq 1 ]]; then + myecho 2+ " * mv $MVopt $filename.pdf \"$OUTPUTFILE\"" + mv $MVopt $filename.pdf "$OUTPUTFILE" else - myecho 2+ " * mv $MVopt -i $filename.pdf \"$OUTF\"" - mv $MVopt -i $filename.pdf "$OUTF" + myecho 2+ " * mv $MVopt -i $filename.pdf \"$OUTPUTFILE\"" + mv $MVopt -i $filename.pdf "$OUTPUTFILE" fi cleanup exit 0 @@ -1580,3 +1574,14 @@ v1.60 (2020/06/24) v1.61 (2020/10/21) - clean up after option '-g' (thanks to Oliver Redner) + +v2.00 (2020/12/17) + - fixed a bug with inner margins + - added --tight-frame option: tells whether the frame should + be tight around the page (and leave horizontal white space + outside the frame), or as large as possible. + - added --config-file option: configuration files (default + extension .xup) can be used to define default values + for frequent situations. + - cleaned-up man page, adding some missing options (thanks + to Louis Gostiaux for pointing undocumented options) diff --git a/Master/texmf-dist/tex/latex/pdfxup/beamer2.xup b/Master/texmf-dist/tex/latex/pdfxup/beamer2.xup new file mode 100644 index 00000000000..c414b039181 --- /dev/null +++ b/Master/texmf-dist/tex/latex/pdfxup/beamer2.xup @@ -0,0 +1,31 @@ +# +# pdfxup configuration for beamer slides (2-up, portrait) +# +## (c) 2020/12/17 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 +## or (at your option) any later version. The latest version of this +## license is in +## +## http://www.latex-project.org/lppl.txt +## +## and version 1.3 or later is part of all distributions of LaTeX version +## 2005/12/01 or later. +## +## This work has the LPPL maintenance status `maintained'. +## The Current Maintainer of this work is Nicolas Markey. + + +# number of rows +NB_COLUMNS=1 +# number of columns +NB_ROWS=2 +# orientation (1=landscape, 0=portrait) +LANDSCAPE=0 +# do not crop margins +KEEP_ORIG_BBOX=1 +# tight frame around each slide +TIGHT_FRAME=1 +# frame width +FRAME_WIDTH=.4pt diff --git a/Master/texmf-dist/tex/latex/pdfxup/beamer4.xup b/Master/texmf-dist/tex/latex/pdfxup/beamer4.xup new file mode 100644 index 00000000000..6337d349a36 --- /dev/null +++ b/Master/texmf-dist/tex/latex/pdfxup/beamer4.xup @@ -0,0 +1,31 @@ +# +# pdfxup configuration for beamer slides (2x2-up, landscape) +# +## (c) 2020/12/17 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 +## or (at your option) any later version. The latest version of this +## license is in +## +## http://www.latex-project.org/lppl.txt +## +## and version 1.3 or later is part of all distributions of LaTeX version +## 2005/12/01 or later. +## +## This work has the LPPL maintenance status `maintained'. +## The Current Maintainer of this work is Nicolas Markey. + + +# number of rows +NB_COLUMNS=2 +# number of columns +NB_ROWS=2 +# orientation (1=landscape, 0=portrait) +LANDSCAPE=1 +# do not crop margins +KEEP_ORIG_BBOX=1 +# tight frame around each slide +TIGHT_FRAME=1 +# frame width +FRAME_WIDTH=.4pt diff --git a/Master/texmf-dist/tex/latex/pdfxup/pdfxup-template.tex b/Master/texmf-dist/tex/latex/pdfxup/pdfxup-template.tex new file mode 100644 index 00000000000..f5b6839f312 --- /dev/null +++ b/Master/texmf-dist/tex/latex/pdfxup/pdfxup-template.tex @@ -0,0 +1,278 @@ +\expandafter\ifx\csname pdfxupfile\endcsname\relax +\PackageError{pdfxup}{This file should not be compiled alone} + {File pdfxup-template.pdf is not meant to be compiled alone. + \MessageBreak + It should only be used via the 'pdfxup' script.} +\fi + +\documentclass{minimal} + \usepackage[margin=0pt,\pdfxupoutputpaper paper]{geometry} + \ifnum\pdfxupoutputlandscape=1\relax\geometry{landscape}\fi + \usepackage{graphicx} + \IfFileExists{grffile.sty}{\usepackage{grffile}}{} + + \topskip=0pt + \parindent=0pt + + \makeatletter + + %% define functions for parsing comma-separated lists of ranges of pages + \newcounter{result}% + \newif\iffound + \def\@parserange#1-#2-#3\@end#4\@end{% + \setcounter{result}{#4}% + \ifnum\value{result}=1\relax + \foundtrue + \setcounter{result}{#1}% + \else + \addtocounter{result}{-1}% + \ifx\relax#3\relax%% means that range contains no - + \else + \addtocounter{result}{#1}% + \ifnum#2<\value{result}\relax + \addtocounter{result}{-#2}% + \else + \foundtrue + \fi + \fi + \fi} + \def\parserange#1#2{\expandafter\@parserange#2-SINGLE-\@end#1\@end} + \def\@parsecsl#1,#2\@end#3\@end{% + \parserange{#3}{#1}% + \iffound\else + \ifx\relax#2\relax\else\@parsecsl#2\@end\value{result}\@end\fi\fi} + %% \nthvalue#1#2 looks for #1-th value in list of intervals #2 + \def\nthvalue#1#2{\foundfalse\expandafter\@parsecsl#2,\@end#1\@end} + %% + + + %% perform various computations: + %% - width and height of image (\hresult and \vresult) + %% - width and height of frame containing image (\hboxsize and \vboxsize) + \newcounter{lastpage} + \newcounter{outpage} + \setcounter{outpage}{\pdfxupnbpages} + \addtocounter{outpage}{-1} + \divide\c@outpage by \pdfxupnbhoriz + \divide\c@outpage by \pdfxupnbvert + \ifbooklet + \divide\c@outpage by 2 + \fi + \stepcounter{outpage} + \ifbooklet + \multiply\c@outpage by 2 + \fi + \setcounter{lastpage}{\value{outpage}} + \multiply\c@lastpage by \pdfxupnbhoriz + \multiply\c@lastpage by \pdfxupnbvert + \makeatother + % + \newlength\outputvmargin + \newlength\outputhmargin + \setlength\outputvmargin{\pdfxupvmargin} + \setlength\outputhmargin{\pdfxuphmargin} + \newlength\innervmargin + \newlength\innerhmargin + \setlength\innervmargin{\pdfxupinnervmargin} + \setlength\innerhmargin{\pdfxupinnerhmargin} + \newlength\outputindivvmargin + \newlength\outputindivhmargin + \setlength\outputindivvmargin{\pdfxupintermvspace} + \setlength\outputindivhmargin{\pdfxupintermhspace} + % + \fboxsep=0pt% + \setlength\fboxrule{\pdfxupframewidth} + \newlength\hresult + \newlength\vresult + \newlength\vboxsize + \newlength\hboxsize + \hresult=\paperwidth + \advance\hresult by -\pdfxupnbhoriz\fboxrule + \advance\hresult by -\pdfxupnbhoriz\fboxrule + \advance\hresult by -\pdfxupnbhoriz\innerhmargin + \advance\hresult by -\pdfxupnbhoriz\innerhmargin + \vresult=\paperheight + \advance\vresult by -\pdfxupnbvert\fboxrule + \advance\vresult by -\pdfxupnbvert\fboxrule + \advance\vresult by -\pdfxupnbvert\innerhmargin + \advance\vresult by -\pdfxupnbvert\innerhmargin + % + \advance\hresult by -2\outputhmargin + \advance\vresult by -2\outputvmargin + % + \advance\hresult by -\pdfxupnbhoriz \outputindivhmargin + \advance\vresult by -\pdfxupnbvert \outputindivvmargin + \advance\hresult by \outputindivhmargin + \advance\vresult by \outputindivvmargin + % + \divide\hresult by \pdfxupnbhoriz + \divide\vresult by \pdfxupnbvert + + \vboxsize=\vresult + \advance\vboxsize by 2\fboxrule + \advance\vboxsize by 2\innervmargin + \hboxsize=\hresult + \advance\hboxsize by 2\fboxrule + \advance\hboxsize by 2\innerhmargin + + + %% compute actual scale by which PDF is shrunk (or extended) + \ifnum\pdfxupemptybb=0\relax + \newcounter{origx} + \setcounter{origx}{\pdfxupw} + \addtocounter{origx}{-\pdfxupx} + \newcounter{origy} + \setcounter{origy}{\pdfxuph} + \addtocounter{origy}{-\pdfxupy} + \newlength\finalx + \newlength\finaly + \finalx=\hresult + \finaly=\vresult + \divide\finalx by \value{origx} + \divide\finaly by \value{origy} + \newwrite\scale + \immediate\openout\scale=\pdfxupfilename.scl + \ifdim\finalx>\finaly + \multiply\finaly by 100 + \immediate\write\scale{\the\finaly} + \else + \multiply\finalx by 100 + \immediate\write\scale{\the\finalx} + \fi + \immediate\closeout\scale + \fi + + + %% start document + \begin{document} + %\tracingoutput=1 + %\tracingpages=1 + %\tracingparagraphs=1 + \makeatletter + \newcounter{curroutpage} + \setcounter{curroutpage}{1} + \addtocounter{curroutpage}{-1} + \newcounter{currpage} + \newcounter{currcol} + \newcounter{currline} + \newcounter{realout} + \newcounter{wmout} + \newcounter{wmoutaux} + \@whilenum \value{outpage}>\value{curroutpage} \do% + {\stepcounter{curroutpage}% + \setcounter{currpage}{\value{curroutpage}}% + \advance\c@currpage by -1% + \multiply\c@currpage by \pdfxupnbhoriz% + \multiply\c@currpage by \pdfxupnbvert% + \hrule \@height\z@% + \setcounter{currline}{0}% + \vskip \outputvmargin% + \@whilenum\value{currline}<\pdfxupnbvert \do% + {\hrule \@height\z@\vskip \outputindivvmargin% + \ifnum\value{currline}>0\vskip \outputindivvmargin\fi% + \global\stepcounter{currline}% + \setcounter{currcol}{0}% + \hskip \outputhmargin% + \@whilenum\value{currcol}<\pdfxupnbhoriz \do% + {\ifnum\value{currcol}>0\hskip\outputindivhmargin\fi% + \global\stepcounter{currcol}% + \global\stepcounter{currpage}% + \ifnum\value{currpage}>\value{lastpage}\else + %% computing page number corresponding to \currline and \currcol + \setcounter{realout}{\value{currpage}}% + \def\ang{0}% + \ifbooklet + \iflongedge + %% long edge: + %% 1->n, 2->1, 3->n-1 (rotated), 4->2(rotated)... + \ifodd\value{realout}% -> 1 or 3 + \addtocounter{realout}{-1}% + \divide\c@realout by 2\relax + \ifodd\value{realout}% -> 3 + \def\ang{180}% + \else% -> 1 + \fi + \setcounter{realout}{-\value{realout}}% + \addtocounter{realout}{\value{outpage}}% + \addtocounter{realout}{\value{outpage}}% + \else% -> 2 or 4 + \divide\c@realout by 2\relax + \ifodd\value{realout}% -> 2 + \else% -> 4 + \def\ang{180}% + \fi + \fi + \else + %% short edge: + %% 1->n, 2->1, 3->2, 4->n-1, 5->n-2, 6->3, 7->4, 8->n-3 + \ifodd\value{realout}% -> 1 or 3 + \addtocounter{realout}{-1}% + \divide\c@realout by 2\relax + \ifodd\value{realout}% -> 3 + \stepcounter{realout} + \else% -> 1 + \setcounter{realout}{-\value{realout}}% + \addtocounter{realout}{\value{outpage}}% + \addtocounter{realout}{\value{outpage}}% + \fi + \else% -> 2 or 4 + \divide\c@realout by 2\relax + \ifodd\value{realout}% -> 2 + \else% -> 4 + \setcounter{realout}{-\value{realout}}% + \stepcounter{realout} + \addtocounter{realout}{\value{outpage}}% + \addtocounter{realout}{\value{outpage}}% + \fi + \fi + \fi %% \iflongedge...\else + \fi %% \ifbooklet + \ifnum\value{realout}>\pdfxupnbpages\relax + %% if page above nb of pages, output blank page + %\hskip\hresult\hskip2\fboxrule + \hskip\hboxsize + \else + %% otherwise compute corresponding page to display + %% first keep realout for watermarking... + \setcounter{wmoutaux}{\value{realout}}% + \setcounter{wmout}{\value{realout}}% + \nthvalue{\value{realout}}{\pdfxuppagelist}% + \iffound\setcounter{realout}{\value{result}}% + \else %% hmmm... problem + \message{I'm messed up counting pages...}% + \fi + %% compute watermarking page and display + \ifx\pdfxupwatermark\@empty\else + \ifnum\pdfxupnbwp<\value{wmoutaux}\relax + \addtocounter{wmoutaux}{-\pdfxupnbwp}% + \addtocounter{wmoutaux}{-1}% + \divide\c@wmoutaux by \pdfxupwperiod\relax + \stepcounter{wmoutaux}% + \multiply\c@wmoutaux by \pdfxupwperiod\relax + \addtocounter{wmout}{-\value{wmoutaux}}% + \fi + \vbox to \vboxsize{\vfill + \hbox to \hboxsize{\hfill + \includegraphics[keepaspectratio,% + height=\vresult,width=\hresult,angle=\ang,% + page=\value{wmout}\pdfxupclipopt]{\pdfxupwatermark}\hfill}\vfill}% + \hskip-\hboxsize\relax + \fi + %% display current page at correct size + \edef\pdfxupinclgr{\includegraphics[\pdfxupbbox,% + keepaspectratio,height=\vresult,width=\hresult,angle=\ang,% + page=\value{realout}\pdfxupclipopt]{\pdfxupfile}}% + \pdfxupwidefbox{\vbox to \vboxsize{\vfill + \hbox to \hboxsize{\hfill + \pdfxuptightfbox{\hskip\innerhmargin\relax + \sbox{0}{\pdfxupinclgr}% + \ht0=\dimexpr\ht0 + \innervmargin\relax + \dp0=\dimexpr\dp0 + \innervmargin\relax + \usebox{0}\hskip\innerhmargin\relax}% + \hfill}\vfill}}% + \fi + \fi}}% + \clearpage% + }% + \makeatother% + \end{document} diff --git a/Master/tlpkg/libexec/ctan2tds b/Master/tlpkg/libexec/ctan2tds index 6596e24e4f5..9d9fb78fc38 100755 --- a/Master/tlpkg/libexec/ctan2tds +++ b/Master/tlpkg/libexec/ctan2tds @@ -2067,6 +2067,7 @@ $standardtex 'pdfscreen', 'overlay.*pdf|but.*pdf|left.*pdf|right\.pdf|pdfscreen.sty', 'pdfslide', '\.jpg|\.sty|\.clo|\.cfg|meta.*\.pdf', 'pdfx', '\.(def|dfu|icc|xmp)$|(glyph|Profiles).*tex|pdfx\.sty|ICC_LIC', + 'pdfxup', '(template\.tex|\.xup)$', 'petri-nets', 'pnets\.tex|pntext\.tex|\.sty|pndraw\.tex|pnversion\.tex|\.sty|pndraw\.tex', 'pgf-blur', 'tikzlibraryshadows.blur.code.tex', 'pgf-spectra', 'spectra.data.tex|' . $standardtex, |