diff options
Diffstat (limited to 'Master/texmf-dist/scripts/pdfjam')
-rwxr-xr-x | Master/texmf-dist/scripts/pdfjam/pdf180 | 11 | ||||
-rwxr-xr-x | Master/texmf-dist/scripts/pdfjam/pdf270 | 11 | ||||
-rwxr-xr-x | Master/texmf-dist/scripts/pdfjam/pdf90 | 11 | ||||
-rwxr-xr-x | Master/texmf-dist/scripts/pdfjam/pdfbook | 55 | ||||
-rwxr-xr-x | Master/texmf-dist/scripts/pdfjam/pdfflip | 9 | ||||
-rwxr-xr-x | Master/texmf-dist/scripts/pdfjam/pdfjam | 691 | ||||
-rwxr-xr-x | Master/texmf-dist/scripts/pdfjam/pdfjam-pocketmod | 57 | ||||
-rwxr-xr-x | Master/texmf-dist/scripts/pdfjam/pdfjam-slides3up | 29 | ||||
-rwxr-xr-x | Master/texmf-dist/scripts/pdfjam/pdfjam-slides6up | 31 | ||||
-rwxr-xr-x | Master/texmf-dist/scripts/pdfjam/pdfjoin | 26 | ||||
-rwxr-xr-x | Master/texmf-dist/scripts/pdfjam/pdfnup | 29 | ||||
-rwxr-xr-x | Master/texmf-dist/scripts/pdfjam/pdfpun | 73 |
12 files changed, 377 insertions, 656 deletions
diff --git a/Master/texmf-dist/scripts/pdfjam/pdf180 b/Master/texmf-dist/scripts/pdfjam/pdf180 deleted file mode 100755 index 6e88947589b..00000000000 --- a/Master/texmf-dist/scripts/pdfjam/pdf180 +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -## -## pdf180: A shell program to rotate pages of PDF files -## -## Author David Firth (http://go.warwick.ac.uk/dfirth) -## -## This is a simple wrapper for pdfjam, version 2.08 -## -exec pdfjam --suffix rotated180 --angle 180 --fitpaper true "$@" - - diff --git a/Master/texmf-dist/scripts/pdfjam/pdf270 b/Master/texmf-dist/scripts/pdfjam/pdf270 deleted file mode 100755 index 3b4abe15318..00000000000 --- a/Master/texmf-dist/scripts/pdfjam/pdf270 +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -## -## pdf270: A shell program to rotate pages of PDF files -## -## Author David Firth (http://go.warwick.ac.uk/dfirth) -## -## This is a simple wrapper for pdfjam, version 2.08 -##. -exec pdfjam --suffix rotated270 --angle 270 --fitpaper true --rotateoversize true "$@" - - diff --git a/Master/texmf-dist/scripts/pdfjam/pdf90 b/Master/texmf-dist/scripts/pdfjam/pdf90 deleted file mode 100755 index dde5df820bb..00000000000 --- a/Master/texmf-dist/scripts/pdfjam/pdf90 +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -## -## pdf90: A shell program to rotate pages of PDF files -## -## Author David Firth (http://go.warwick.ac.uk/dfirth) -## -## This is a simple wrapper for pdfjam, version 2.08 -## -exec pdfjam --suffix rotated90 --angle 90 --fitpaper true --rotateoversize true "$@" - - diff --git a/Master/texmf-dist/scripts/pdfjam/pdfbook b/Master/texmf-dist/scripts/pdfjam/pdfbook deleted file mode 100755 index c6490b3881f..00000000000 --- a/Master/texmf-dist/scripts/pdfjam/pdfbook +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/sh -## -## pdfbook: Rearrange pages of one or more PDF files into 2-up signatures -## -## Author David Firth (http://go.warwick.ac.uk/dfirth), with help -## from Marco Pessotto -## -## This is a simple wrapper for pdfjam, version 2.08 -## -case $1 in - --short-edge) - shortedge=true ; - shift ; - ;; - *) - ;; -esac -for arg -do - case $arg in - --signature*) - ## catches both --signature and --signature* - signature=true ; break - ;; - *) ;; - esac -done -## -## If $signature is empty, we need to use a default: -## -if test -z "$signature" ; then - signature="--signature 4" -else - signature="" -fi -## -## Make the call to pdfjam: -## -if test -z "$shortedge" -then - exec pdfjam --booklet true --landscape --suffix book $signature "$@" -else - (kpsewhich everyshi.sty >/dev/null) || { - echo "the 'everyshi' package is not installed."; exit 1 - } - exec pdfjam --booklet true --landscape --suffix book $signature \ - --preamble '\usepackage{everyshi} -\makeatletter -\EveryShipout{\ifodd\c@page\pdfpageattr{/Rotate 180}\fi} -\makeatother -' "$@" -fi - - - diff --git a/Master/texmf-dist/scripts/pdfjam/pdfflip b/Master/texmf-dist/scripts/pdfjam/pdfflip deleted file mode 100755 index 3088e56a3e9..00000000000 --- a/Master/texmf-dist/scripts/pdfjam/pdfflip +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -## -## pdfflip: A shell program to "flip over" the pages of PDF files -## -## Author David Firth (http://go.warwick.ac.uk/dfirth) -## -## This is a simple wrapper for pdfjam, version 2.08 -## -exec pdfjam --suffix flipped --reflect true --fitpaper true "$@" diff --git a/Master/texmf-dist/scripts/pdfjam/pdfjam b/Master/texmf-dist/scripts/pdfjam/pdfjam index e12b466b43b..1f7d84454a2 100755 --- a/Master/texmf-dist/scripts/pdfjam/pdfjam +++ b/Master/texmf-dist/scripts/pdfjam/pdfjam @@ -1,16 +1,17 @@ #!/bin/sh -version=2.08 +version=3.03 ######################################################################### ## ## ## pdfjam: A shell-script interface to the "pdfpages" LaTeX package ## ## ------ ## ## ## -## Author: David Firth (http://go.warwick.ac.uk/dfirth) ## +## Author: David Firth (http://warwick.ac.uk/dfirth) ## ## ## -## Usage: see http://go.warwick.ac.uk/pdfjam or "pdfjam --help" ## +## Usage: see https://github.com/DavidFirth/pdfjam ## +## or "pdfjam --help" ## ## ## ## Relies on: ## -## -- pdflatex ## +## -- pdflatex (or xelatex or lualatex) ## ## -- the 'pdfpages' package for LaTeX (ideally version >= 0.4f) ## ## ## ## License: GPL version 2 or later. This software comes with ## @@ -26,6 +27,197 @@ version=2.08 ## ## ######################################################################### ## +## HELP TEXT +## +## Defines the output of 'pdfjam --help' +## +helptext=" +pdfjam is a shell-script front end to the LaTeX 'pdfpages' package (for +which, see http://www.ctan.org/tex-archive/macros/latex/contrib/pdfpages). + +Usage: pdfjam [OPTIONS] [--] [FILE1 [SEL1]] [FILE2 [SEL2]]... +where +* 'FILE1' etc. are PDF files (JPG and PNG files are also allowed). For + input from /dev/stdin, use the special name '/dev/stdin' in place of any + of FILE1, FILE2, etc: this can be mixed with 'real' files as needed, to + allow input through a pipe (note that if /dev/stdin is connected to tty, + an error results). If 'FILE1' is absent, pdfjam will use '/dev/stdin' + (and will use '-' for the page selection -- see next item). +* 'SEL1' is a page selection for FILE1, etc. + To select all pages (the default) use '-'. See the pdfpages manual for + more details. An example: + ... file1 '{},2,4-6,9-' ... + makes an empty page, followed by pages 2,4,5,6 of file1, followed by pages + 9 onwards (up to the end of file1). + A page selection can be applied to more than one file, e.g., + ... file1 file2 file3 1-7 ... + applies page selection '1-7' to all three files; but for example + ... file1 file2 2- file3 1-7 ... + would apply the page selection '2-' to file1 and file2, and '1-7' + to file3. A page selection applies to all the files *immediately* + preceding it in the argument list. A missing page selection defaults to + '-'; this includes the case where 'FILE1' is absent and so /dev/stdin gets + used by default. +* 'options' are pdfpages specifications in the form '--KEY VALUE' (see + below), or + --help (or -h, or -u) + Output this text only; no processing of PDF files. + --configpath + Output the 'configpath' variable and exit immediately; no + processing of PDF files. + --version (or -V) + Output the version number of pdfjam and exit immediately; no + processing of PDF files. + --quiet (or -q) + Suppress verbose commentary on progress. + --batch + Run pdfjam sequentially on each input file in turn, and + produce a separate output file for each input, rather + than the default behaviour (which is a single run of + pdfjam on all of the input files, producing a single + output document). For the location of output + files, see '--outfile'. The --batch option cannot be + used in the case of input from stdin. + --outfile PATH (or -o PATH) + Specifies where the output file(s) will go. If PATH is an + existing directory, pdfjam will attempt to write its + output PDF file(s) there, with name(s) derived from the + input file name(s) and the --suffix option (see below). + Otherwise the output file will be PATH. If '/dev/stdin' + is the only or last input file, PATH cannot be a directory. + Your current default PATH for output is: + $outFile + --suffix STRING + Specifies a suffix for output file names, to be used when + --outfile is either (a) a directory, or + (b) not specified in a --batch call. + A good STRING should be descriptive: for example, + --suffix 'rotated' + would append the text '-rotated' to the name of the input + file in order to make the output file name, as in + 'myfile-rotated.pdf'. The STRING must not have zero + length. + [Default for you at this site: suffix=$suffix] + --checkfiles + --no-checkfiles + If the Unix 'file' utility is available, with options + -L and -b, the output of 'file -Lb FILE1' should be + 'PDF document...' where '...' gives version information. + If this is the case on your system you should use + '--checkfiles'; otherwise use '--no-checkfiles', + in which case all input PDF files must have .pdf or .PDF + as their name extension. + [Default for you at this site: checkfiles=$checkfiles] + --preamble STRING + Append the supplied STRING to the preamble of the LaTeX + source file(s), immediately before the '\begin{document}' + line. An example: + pdfjam --nup 2x2 myfile.pdf -o myfile-4up.pdf \\ + --preamble '\usepackage{fancyhdr} \pagestyle{fancy}' + The '--preamble' option can be used, for example, to load + LaTeX packages and/or to set global options. If '--preamble' + is used more than once in the call, the supplied preamble + strings are simply concatenated. For a note on avoiding + clashes, see the PDFjam-README file (also available at + http://www.pdfjam.net). + --keepinfo + --no-keepinfo + Preserve (or not) Title, Author, Subject and Keywords + (from the last input PDF file, if more than one) in the + output PDF file. This requires the pdfinfo utility, from + the xpdf package, and the LaTeX 'hyperref' package; if + either of those is not available, '--keepinfo' is ignored. + [Default for you at this site: keepinfo=$keepinfo] + --pdftitle STRING + --pdfauthor STRING + --pdfsubject STRING + --pdfkeywords STRING + Provide text for the Title, Author, Subject and Keywords + in the output PDF file. Requires the LaTeX 'hyperref' + package. These options, individually, over-ride --keepinfo. + --landscape + --no-landscape + Specify landscape page orientation (or not) in the + output PDF file. + [Default for you at this site: landscape=$landscape] + --twoside + --no-twoside + Specify (or not) the 'twoside' document class option. + [Default for you at this site: twoside=$twoside] + --paper PAPERSPEC (or simply --PAPERSPEC) + Specify a LaTeX paper size, for example + '--paper a4paper' or simply '--a4paper' for ISO A4 paper. + If the LaTeX 'geometry' package is installed, a wider range + of paper sizes is available. For details see documentation + for LaTeX and/or the 'geometry' package. + [Default for you at this site: paper=$paper] + --papersize '{WIDTH,HEIGHT}' + Specify a custom paper size, e.g., + --papersize '{10in,18cm}' + (Note the braces, and the comma!) + If the 'geometry' package is not found, this has no effect. + --pagecolor RGBSPEC + Specify a background colour for the output pages. The + RGBSPEC must be a comma-separated trio of integers + between 0 and 255. An example: + --pagecolor 150,200,150 + [Default is no background colour] + --tidy + --no-tidy + Specify whether the temporary directory created by + pdfjam should be deleted. Use '--no-tidy' to help debug + most errors. + [Default for you at this site: tidy=$tidy] + --latex PATHTOLATEX + Specify the LaTeX engine to be used (one of pdflatex, + xelatex, lualatex). The PATHTOLATEX string must be + the full path to a suitable LaTeX executable (for example + /usr/bin/xelatex on many unix systems). + [Default for you at this site: latex=$latex] + --runs N + Run latex N times, for each output document made. + [Default for you at this site: runs=$runs] + --vanilla + Suppress the reading of any site-wide or user-specific + configuration files. + --KEY VALUE + Specify options to '\includepdfmerge', in the LaTeX + 'pdfpages' package. Here KEY is the name of any of the + many options for '\includepdfmerge', and VALUE is a + corresponding value. Examples are + --nup 2x1 (for 2-up side-by-side imposition) + --scale 0.7 (to scale all input pages to 70% size) + --offset '1cm 0.5cm' + (to offset all pages -- note the quotes!) + --frame true (to put a frame round each input page) + --trim '1cm 2cm 1cm 2cm' --clip true + (to trim those amounts from left, bottom, + right and top, respectively, of input + pages) + etc., etc. For more information see the manual for + the 'pdfpages' package, at + http://www.ctan.org/tex-archive/macros/latex/contrib/pdfpages +* '--' can be used to signal that there are no more options to come. + +Defaults for the options '--suffix', '--keepinfo', '--paper', '--outfile', +'--landscape', '--twoside', '--tidy', '--latex', '--runs', '--checkfiles' +and '--preamble' can be set in site-wide or user-specific configuration files. +The path that is searched for site-wide configuration files (named pdfjam.conf) +at this installation is + $configpath +This configuration path can be changed by editing the pdfjam script if +necessary. Any user-specific configuration should be put in a file named +.pdfjam.conf in your home directory. (All of these files are ignored +if the '--vanilla' argument is used.) + +For more information, including a sample configuration file, see +https://github.com/DavidFirth/pdfjam. +" +## +## END OF HELP TEXT +## +######################################################################### +## ## PRELIMINARIES ## ## First determine: @@ -50,7 +242,8 @@ do batch=true ; ;; --help | -u | -h) - help=true ; + printf "%s\n" "$helptext" ; + exit 0 ; ;; --vanilla) vanilla=true ; @@ -73,11 +266,11 @@ OIFS="$IFS" ## ## Record the full filename of the current working diractory ## -pwd=`pwd` +pwd=$(pwd) ## ## Trap interrupts so that they kill everything: ## -trap 'IFS=$OIFS; exit 1' 1 2 9 15 +trap 'IFS=$OIFS; exit 1' 1 2 15 ## ## The following will be useful for readability of the script: ## @@ -95,7 +288,7 @@ escape_chars () { prattle () { ## second argument here is non-null for continuation lines if test $verbose = true; then prefix1=" pdfjam:" ; - prefix2=`printf "%s" "$prefix1" | sed 's/pdfjam:/ /'` ; + prefix2=$(printf "%s" "$prefix1" | sed 's/pdfjam:/ /') ; indent="" ; if test "$PDFJAM_CALL_NUMBER" -gt 0 && test "$batch" != true @@ -106,7 +299,7 @@ prattle () { ## second argument here is non-null for continuation lines lineCounter=0 ; for line in ${1} do - lineCounter=`expr $lineCounter + 1` ; + lineCounter=$((lineCounter + 1)) ; if test $lineCounter -eq 1 && test ! -n "${2}" ; then if test -w "$PDFJAM_MESSAGES_FILE" @@ -149,22 +342,21 @@ prattle "This is pdfjam version ${version}." ## once, the last instance prevails.) ## ## An example configuration file can be found at -## http://go.warwick.ac.uk/pdfjam +## https://github.com/DavidFirth/pdfjam ## ## The path searched for site-wide configuration files can be changed ## by editing the variable 'configpath' at the top of this file. ## ## -## First check whether 'pdflatex' is in the user's path: -## -pdflatex=pdflatex -(hash pdflatex >/dev/null 2>&1) || pdflatex="not found" +## First get the full path (if it exists) to pdflatex: ## +latex=$(command -v pdflatex) +if [ -z "$latex" ] ; then latex="not found" ; fi ## -## Likewise for the pdfinfo utility (only needed for `--keepinfo'): +## Likewise for the pdfinfo (only needed for `--keepinfo'): ## -pdfinfo='pdfinfo' -(hash pdfinfo >/dev/null 2>&1) || pdfinfo="not found" +pdfinfo=$(command -v pdfinfo) +if [ -z "$pdfinfo" ] ; then pdfinfo="not found"; fi ## ## ## Next a permitted location for temporary files on your system: @@ -179,6 +371,8 @@ outFile="$pwd" ## Output to the current working directory ## ## A few more default settings for pdfjam: ## +runs=1 ## Run latex just once +## tidy='true' ## Delete all temporary files at the end ## keepinfo='false' ## Don't try to preserve "pdfinfo" data @@ -193,7 +387,23 @@ suffix='pdfjam' ## Default filename suffix to be used when ## preamble='' ## Default LaTeX preamble string. ## -paper='a4paper' ## Default paper size is ISO A4. +## Guess default paper size from locale if possible, otherwise A4 +## +if command -v locale >/dev/null ; then + paperheight=$(locale -k LC_PAPER | sed -e '1!d' -e 's/.*=//') ; + case $paperheight in + 297) + paper='a4paper' ; + ;; + 279) + paper='letterpaper' ; + ;; + *) + paper='a4paper' ; + ;; + esac +else paper='a4paper' ; ## fallback paper size is ISO A4 +fi ## ## END OF SETTINGS MADE DIRECTLY WITHIN THE SCRIPT ## @@ -204,8 +414,8 @@ if test "$vanilla" != true then if test "$PDFJAM_CALL_NUMBER" = 0 ## not a secondary call to pdfjam then - configFiles=`printf "%s" "$configpath" | \ - sed 's/:/\/pdfjam.conf:/g; s/$/\/pdfjam.conf/'` + configFiles=$(printf "%s" "$configpath" | \ + sed 's/:/\/pdfjam.conf:/g; s/$/\/pdfjam.conf/') configFiles="${configFiles}:$HOME/.pdfjam.conf" PDFJAM_CONFIG="" prattle "Reading any site-wide or user-specific defaults..." @@ -213,13 +423,13 @@ then for d in $configFiles do if test -f "$d"; then - change=`sed '/^ *#.*/d ; s/ *#.*//; s/^ *//' "$d"` + change=$(sed '/^ *#.*/d ; s/ *#.*//; s/^ *//' "$d") comment="## ${newline}## From ${d}: ${newline}##" PDFJAM_CONFIG="$PDFJAM_CONFIG$comment$newline$change$newline" fi done IFS="$OIFS" - PDFJAM_CONFIG=`printf "%s" "$PDFJAM_CONFIG" | sed 's/^/ /'` + PDFJAM_CONFIG=$(printf "%s" "$PDFJAM_CONFIG" | sed 's/^/ /') if test "$batch" = true ; then export PDFJAM_CONFIG ; fi if test -z "$PDFJAM_CONFIG" then @@ -236,207 +446,29 @@ else prattle "files will be read." 1 fi fi +## For backwards compatibility, check here for a $pdflatex setting in the config file +if [ -n "${pdflatex:-}" ] ; then latex="$pdflatex" ; fi ## ## END OF CONFIGURATION BLOCK ## ######################################################################### ## -## HELP TEXT -## -## Defines the output of 'pdfjam --help' -## -helptext=" -pdfjam is a shell-script front end to the LaTeX 'pdfpages' package (for -which, see http://www.ctan.org/tex-archive/macros/latex/contrib/pdfpages). - -Usage: pdfjam [OPTIONS] [--] [FILE1 [SEL1]] [FILE2 [SEL2]]... -where -* 'FILE1' etc. are PDF files (JPG and PNG files are also allowed). For - input from /dev/stdin, use the special name '/dev/stdin' in place of any - of FILE1, FILE2, etc: this can be mixed with 'real' files as needed, to - allow input through a pipe (note that if /dev/stdin is connected to tty, - an error results). If 'FILE1' is absent, pdfjam will use '/dev/stdin' - (and will use '-' for the page selection -- see next item). -* 'SEL1' is a page selection for FILE1, etc. - To select all pages (the default) use '-'. See the pdfpages manual for - more details. An example: - ... file1 '{},2,4-5,9-' ... - makes an empty page, followed by pages 2,4,5,6 of file1, followed by pages - 9 onwards (up to the end of file1). - A page selection can be applied to more than one file, e.g., - ... file1 file2 file3 1-7 ... - applies page selection '1-7' to all three files; but for example - ... file1 file2 2- file3 1-7 ... - would apply the page selection '2-' to file1 and file2, and '1-7' - to file3. A page selection applies to all the files *immediately* - preceding it in the argument list. A missing page selection defaults to - '-'; this includes the case where 'FILE1' is absent and so /dev/stdin gets - used by default. -* 'options' are pdfpages specifications in the form '--KEY VALUE' (see - below), or - --help (or -h, or -u) - Output this text only; no processing of PDF files. - --configpath - Output the 'configpath' variable and exit immediately; no - processing of PDF files. - --version (or -V) - Output the version number of pdfjam and exit immediately; no - processing of PDF files. - --quiet (or -q) - Suppress verbose commentary on progress. - --batch - Run pdfjam sequentially on each input file in turn, and - produce a separate output file for each input, rather - than the default behaviour (which is a single run of - pdfjam on all of the input files, producing a single - output document). For the location of output - files, see '--outfile'. The --batch option cannot be - used in the case of input fron stdin. - --outfile PATH (or -o PATH) - Specifies where the output file(s) will go. If PATH is an - existing directory, pdfjam will attempt to write its - output PDF file(s) there, with name(s) derived from the - input file name(s) and the --suffix option (see below). - Otherwise the output file will be PATH. If '/dev/stdin' - is the only or last input file, PATH cannot be a directory. - Your current default PATH for output is: - $outFile - --suffix STRING - Specifies a suffix for output file names, to be used when - --outfile is either (a) a directory, or - (b) not specified in a --batch call. - A good STRING should be descriptive: for example, - --suffix 'rotated' - would append the text '-rotated' to the name of the input - file in order to make the output file name, as in - 'myfile-rotated.pdf'. The STRING must not have zero - length. - [Default for you at this site: suffix=$suffix] - --checkfiles - --no-checkfiles - If the Unix 'file' utility is available, with options - -L and -b, the output of 'file -Lb FILE1' should be - 'PDF document...' where '...' gives version information. - If this is the case on your system you should use - '--checkfiles'; otherwise use '--no-checkfiles', - in which case all input PDF files must have .pdf or .PDF - as their name extension. - [Default for you at this site: checkfiles=$checkfiles] - --preamble STRING - Append the supplied STRING to the preamble of the LaTeX - source file(s), immediately before the '\begin{document}' - line. An example: - pdfjam --nup 2x2 myfile.pdf -o myfile-4up.pdf \\ - --preamble '\usepackage{fancyhdr} \pagestyle{fancy}' - The '--preamble' option can be used, for example, to load - LaTeX packages and/or to set global options. If '--preamble' - is used more than once in the call, the supplied preamble - strings are simply concatenated. - --keepinfo - --no-keepinfo - Preserve (or not) Title, Author, Subject and Keywords - (from the last input PDF file, if more than one) in the - output PDF file. This requires the pdfinfo utility, from - the xpdf package, and the LaTeX 'hyperref' package; if - either of those is not available, '--keepinfo' is ignored. - [Default for you at this site: keepinfo=$keepinfo] - --pdftitle STRING - --pdfauthor STRING - --pdfsubject STRING - --pdfkeywords STRING - Provide text for the Title, Author, Subject and Keywords - in the output PDF file. Requires the LaTeX 'hyperref' - package. These options, individually, over-ride --keepinfo. - --landscape - --no-landscape - Specify landscape page orientation (or not) in the - output PDF file. - [Default for you at this site: landscape=$landscape] - --twoside - --no-twoside - Specify (or not) the 'twoside' document class option. - [Default for you at this site: twoside=$twoside] - --paper PAPERSPEC (or simply --PAPERSPEC) - Specify a LaTeX paper size, for example - '--paper a4paper' or simply '--a4paper' for ISO A4 paper. - If the LaTeX 'geometry' package is installed, a wider range - of paper sizes is available. For details see documentation - for LaTeX and/or the 'geometry' package. - [Default for you at this site: paper=$paper] - --papersize '{WIDTH,HEIGHT}' - Specify a custom paper size, e.g., - --papersize '{10in,18cm}' - (Note the braces, and the comma!) - If the 'geometry' package is not found, this has no effect. - --pagecolor RGBSPEC - Specify a background colour for the output pages. The - RGBSPEC must be a comma-separated trio of integers - between 0 and 255. An example: - --pagecolor 150,200,150 - [Default is no background colour] - --tidy - --no-tidy - Specify whether the temporary directory created by - pdfjam should be deleted. Use '--no-tidy' to help debug - most errors. - [Default for you at this site: tidy=$tidy] - --vanilla - Suppress the reading of any site-wide or user-specific - configuration files. - --KEY VALUE - Specify options to '\includepdfmerge', in the LaTeX - 'pdfpages' package. Here KEY is the name of any of the - many options for '\includepdfmerge', and VALUE is a - corresponding value. Examples are - --nup 2x1 (for 2-up side-by-side imposition) - --scale 0.7 (to scale all input pages to 70% size) - --offset '1cm 0.5cm' - (to offset all pages -- note the quotes!) - --frame true (to put a frame round each input page) - --trim '1cm 2cm 1cm 2cm' --clip true - (to trim those amounts from left, bottom, - right and top, respectively, of input - pages) - etc., etc. For more information see the manual for - the 'pdfpages' package, at - http://www.ctan.org/tex-archive/macros/latex/contrib/pdfpages -* '--' can be used to signal that there are no more options to come. - -Defaults for the options '--suffix', '--keepinfo', '--paper', '--outfile', -'--landscape', '--twoside', '--tidy', '--checkfiles' and '--preamble' can be -set in site-wide or user-specific configuration files. The path that is -searched for site-wide configuration files (named pdfjam.conf) at this -installation is - $configpath -This configuration path can be changed by editing the pdfjam script if -necessary. Any user-specific configuration should be put in a file named -.pdfjam.conf in your home directory. (All of these files are ignored -if the '--vanilla' argument is used.) - -For more information, including an example configuration file, see -http://go.warwick.ac.uk/pdfjam. -" -## -## END OF HELP TEXT -## -######################################################################### -## ## ERROR CODES ## E_USAGE=64 # command line usage error -E_DATAERR=65 # data format error E_NOINPUT=66 # cannot open input E_UNAVAILABLE=69 # service unavailable E_SOFTWARE=70 # internal software error +E_OSFILE=72 # file does not exist or cannot be opened E_CANTCREATE=73 # can't create (user) output file E_CONFIG=78 # configuration error ## ## Define a function to print an error message and exit: ## error_exit () { - if (test -r "$PDFJAM_MESSAGES_FILE") + if [ -r "$PDFJAM_MESSAGES_FILE" ] then cat "$PDFJAM_MESSAGES_FILE" >&2 - else printf "$messages" 1>&2 + else printf "%s" "$messages" 1>&2 fi printf " pdfjam ERROR: %s\n" "$1" 1>&2 ; exit "$2" ; @@ -486,19 +518,20 @@ while test -n "${1}${2}"; do shift ; continue ; ;; - --help | -u | -h) - printf "%s\n" "$helptext" ; - exit 0;; --configpath) printf "%s\n" "$configpath" ; exit 0;; --* | -q | -o) if test "$pageSpecAwaited" = true ; then ## fill in any missing page specs before continuing - fileSpec=`printf "%s" "$fileSpec" | sed 's/|awaited/|-/g'` + fileSpec=$(printf "%s" "$fileSpec" | sed 's/|awaited/|-/g') pageSpecAwaited=false fi case ${1} in + --latex) + latex="${2}" ; + callOptions="$callOptions --latex ${2}" ; + shift ;; --batch) batch=true ; ;; @@ -513,7 +546,7 @@ while test -n "${1}${2}"; do outFile="${2}" ; if test "$batch" = true then - outFile=`escape_chars "$outFile"` + outFile=$(escape_chars "$outFile") fi callOptions="$callOptions --outfile $outFile" ; shift ;; @@ -523,7 +556,7 @@ while test -n "${1}${2}"; do suffix="${2}" ; if test "$batch" = true then - suffix=`escape_chars "$suffix"` + suffix=$(escape_chars "$suffix") fi callOptions="$callOptions --suffix $suffix" shift @@ -533,6 +566,16 @@ while test -n "${1}${2}"; do $E_USAGE ; fi ;; + --runs) + runs="${2}" ; + ## check if the argument is a number > 0 + if [ "$runs" -lt 1 ] 2> /dev/null; then + error_exit \ + "'--runs' number must be at least 1" \ + $E_USAGE ; + fi + callOptions="$callOptions --runs ${2}" ; + shift ;; --tidy) tidy=true ; callOptions="$callOptions --tidy" ; @@ -557,7 +600,7 @@ while test -n "${1}${2}"; do pdfTitle="${2}" ; if test "$batch" = true then - pdfTitle=`escape_chars "$pdfTitle"` + pdfTitle=$(escape_chars "$pdfTitle") fi callOptions="$callOptions --pdftitle $pdfTitle" ; shift ;; @@ -565,7 +608,7 @@ while test -n "${1}${2}"; do pdfAuthor="${2}" ; if test "$batch" = true then - pdfAuthor=`escape_chars "$pdfAuthor"` + pdfAuthor=$(escape_chars "$pdfAuthor") fi callOptions="$callOptions --pdfauthor $pdfAuthor" ; shift ;; @@ -573,7 +616,7 @@ while test -n "${1}${2}"; do pdfSubject="${2}" ; if test "$batch" = true then - pdfSubject=`escape_chars "$pdfSubject"` + pdfSubject=$(escape_chars "$pdfSubject") fi callOptions="$callOptions --pdfsubject $pdfSubject" ; shift ;; @@ -581,7 +624,7 @@ while test -n "${1}${2}"; do pdfKeywords="${2}" ; if test "$batch" = true then - pdfKeywords=`escape_chars "$pdfKeywords"` + pdfKeywords=$(escape_chars "$pdfKeywords") fi callOptions="$callOptions --pdfkeywords $pdfKeywords" ; shift ;; @@ -596,7 +639,7 @@ while test -n "${1}${2}"; do --a4paper | --a5paper | --b5paper | --letterpaper | \ --executivepaper | --legalpaper) ## standard LaTeX paper sizes - paper=`printf "%s" "${1}" | sed 's/^--//'` ; + paper=$(printf "%s" "${1}" | sed 's/^--//') ; callOptions="$callOptions ${1}" ; ;; --a0paper | --a1paper | --a2paper | --a3paper | \ @@ -605,7 +648,7 @@ while test -n "${1}${2}"; do ## the 'geometry' package is needed if test "$geometry" != false ; then - paper=`printf "%s" "${1}" | sed 's/^--//'` ; + paper=$(printf "%s" "${1}" | sed 's/^--//') ; callOptions="$callOptions ${1}" ; geometry=true ; fi ; @@ -640,7 +683,7 @@ while test -n "${1}${2}"; do shift ;; --*) ## options for \includepdfmerge - argName=`printf "%s" "${1}" | sed 's/^--//'`; + argName=$(printf "%s" "${1}" | sed 's/^--//'); value="${2}" miscOptions=$miscOptions,"$argName=$value" ; ## saved for possible use in LaTeX file @@ -663,8 +706,8 @@ while test -n "${1}${2}"; do inputFromStdin=true ;; -) if test "$pageSpecAwaited" = true ; then - fileSpec=`printf "%s" "$fileSpec" | \ - sed 's/|awaited/|-/g'` + fileSpec=$(printf "%s" "$fileSpec" | \ + sed 's/|awaited/|-/g') pageSpecAwaited=false else error_exit "no PDF/JPG/PNG file found at ${1}" \ @@ -674,10 +717,10 @@ while test -n "${1}${2}"; do ## source files and page selections; if not, we'll quit if test "$checkfiles" = true ; ## not always available then - case `file -Lb "${1}"` in + case $(file -Lb "${1}") in "PDF document"*|"JPEG image data"*|"PNG image"*) ## it's a PDF file (or JPG/PNG) as expected - fileSpec="$fileSpec${newline}"${1}"|awaited" + fileSpec="$fileSpec${newline}${1}|awaited" pageSpecAwaited=true ;; *) @@ -691,8 +734,8 @@ while test -n "${1}${2}"; do *) ## if page spec needed, assume this is it; ## otherwise something is wrong if test "$pageSpecAwaited" = true ; then - fileSpec=`printf "%s" "$fileSpec" | \ - sed "s/|awaited/|$1/g"` + fileSpec=$(printf "%s" "$fileSpec" | \ + sed "s/|awaited/|$1/g") pageSpecAwaited=false else error_exit "no PDF/JPG/PNG file found at ${1}" \ @@ -715,8 +758,8 @@ while test -n "${1}${2}"; do *) ## if page spec needed, assume this is it; ## otherwise something is wrong if test "$pageSpecAwaited" = true ; then - fileSpec=`printf "%s" "$fileSpec" | \ - sed "s/|awaited/|$1/g"` + fileSpec=$(printf "%s" "$fileSpec" | \ + sed "s/|awaited/|$1/g") pageSpecAwaited=false else error_exit "no PDF/JPG/PNG file found at ${1}" \ @@ -733,7 +776,7 @@ done ## ## Use the default page spec for any that remain unspecified: ## -fileSpec=`printf "%s" "$fileSpec" | sed '/^$/d; s/^ //; s/|awaited$/|-/'` +fileSpec=$(printf "%s" "$fileSpec" | sed '/^$/d; s/^ //; s/|awaited$/|-/') ## ## Check whether input from stdin should be used by default: if test $PDFJAM_CALL_NUMBER -eq 0 && test "$inputFromStdin" != true @@ -749,14 +792,14 @@ fi ## ## Delete leading comma from $miscOptions: ## -miscOptions=`printf "%s" "$miscOptions" | sed 's/^,//'` +miscOptions=$(printf "%s" "$miscOptions" | sed 's/^,//') ## if test -n "$preamble" then callOptions="$callOptions --preamble '$preamble'" fi ## Delete leading space from $callOptions: ## -callOptions=`printf "%s" "$callOptions" | sed 's/^ //'` +callOptions=$(printf "%s" "$callOptions" | sed 's/^ //') ## ## Set up a document options variable: ## @@ -787,7 +830,7 @@ then esac fi documentOptions="$paper","$orientation","$twoside" -documentOptions=`printf "%s" "$documentOptions" | sed 's/^,//' | sed 's/,$//'` +documentOptions=$(printf "%s" "$documentOptions" | sed 's/^,//' | sed 's/,$//') ## ## END OF ARGUMENT PROCESSING ## @@ -799,18 +842,16 @@ documentOptions=`printf "%s" "$documentOptions" | sed 's/^,//' | sed 's/,$//'` ## if test $PDFJAM_CALL_NUMBER -eq 0 ## not a secondary call then - ## Check whether there's a pdflatex, if "$pdflatex" is still unset: - case $pdflatex in + ## Check whether there's a suitable latex to use: + case $latex in "not found") error_exit "can't find pdflatex!" $E_UNAVAILABLE ;; - pdflatex) - ;; - *) ## $pdflatex was set in a configuration file - if test ! -x "$pdflatex" + *) ## + if test ! -x "$latex" then error_exit \ - "configuration error, $pdflatex is not an executable file" \ + "configuration error, $latex is not an executable file" \ $E_CONFIG fi ;; @@ -818,7 +859,7 @@ then ## ## Check that necessary LaTeX packages are installed: ## - modifyPath=`printf "%s" "$pdflatex" | sed 's/\/[^\/]*$//'` + modifyPath=$(printf "%s" "$latex" | sed 's/\/[^\/]*$//') if [ -n "$modifyPath" ] ; then PATH="$modifyPath:$PATH" export PATH @@ -853,7 +894,7 @@ then hyperref=false fi if test "$geometry" = true - ## if, if the 'geometry' package is needed for paper size + ## ie, if the 'geometry' package is needed for paper size then (kpsewhich geometry.sty >/dev/null) || { prattle "LaTeX package geometry.sty is not installed, so only the" @@ -911,25 +952,22 @@ fi ## Use mktemp if possible; otherwise fall back on mkdir, ## with random name to make file collisions less likely. ## -original_umask=`umask` +original_umask=$(umask) umask 177 if test $PDFJAM_CALL_NUMBER = 0 ## don't repeat this work for secondary calls then PDFJAM_TEMP_DIR='' trap 'IFS="$OIFS"; \ if test $tidy != false ; then cd "$pwd"; rm -rf "$PDFJAM_TEMP_DIR"; fi; exit 1' \ - 1 2 9 15 + 1 2 15 trap 'IFS="$OIFS"; \ if test $tidy != false ; then cd "$pwd"; rm -rf "$PDFJAM_TEMP_DIR"; fi' 0 { - PDFJAM_TEMP_DIR=` - (umask 077 && mktemp -d "$tempfileDir/pdfjam-XXXXXX") 2>/dev/null - ` && + PDFJAM_TEMP_DIR=$( (umask 077 && mktemp -d "$tempfileDir/pdfjam-XXXXXX") 2>/dev/null) && test -n "$PDFJAM_TEMP_DIR" && test -d "$PDFJAM_TEMP_DIR" } || { ## We'll use awk to make random number, for portability - random=` - awk 'END { srand(); printf ("%d\n", rand()*1000000); }' /dev/null` + random=$(awk 'END { srand(); printf ("%d\n", rand()*1000000); }' /dev/null) PDFJAM_TEMP_DIR="$tempfileDir"/pdfjam"$$"-"$random" (umask 077 && mkdir "$PDFJAM_TEMP_DIR") } || exit $? @@ -942,13 +980,17 @@ then PDFJAM_MESSAGES_FILE="$PDFJAM_TEMP_DIR"/messages.txt export PDFJAM_MESSAGES_FILE ## so that secondary calls can write messages there as well - printf "$messages" > "$PDFJAM_MESSAGES_FILE" ## initial file contents + printf "%s" "$messages" > "$PDFJAM_MESSAGES_FILE" ## initial file contents messages="" ## we won't be using this variable again! else - PDFJAM_TEMP_DIR="$PDFJAM_TEMP_DIR"/"file$PDFJAM_CALL_NUMBER" + PDFJAM_TEMP_DIR="$PDFJAM_TEMP_DIR/file$PDFJAM_CALL_NUMBER" (umask 077 && mkdir "$PDFJAM_TEMP_DIR") fi -umask $original_umask +umask "$original_umask" +## Next is from the Cygwin patch contributed by Lucas +case $(uname) in + *CYGWIN*) PDFJAM_TEMP_DIR=$(cygpath -w "$PDFJAM_TEMP_DIR");; +esac ## ## TEMPORARY DIRECTORY ALL DONE ## @@ -970,13 +1012,13 @@ if test "$batch" = true ; then fi IFS="$newline" for k in $fileSpec ; do - sourcePath=`printf "%s" "$k" | sed 's/|[^|]*$//'` - pageSpec=`printf "%s" $k | sed 's/.*|//'` - callNumber=`expr $PDFJAM_CALL_NUMBER + 1` + sourcePath=$(printf "%s" "$k" | sed 's/|[^|]*$//') + pageSpec=$(printf "%s" $k | sed 's/.*|//') + callNumber=$((PDFJAM_CALL_NUMBER + 1)) prattle "--" prattle "Processing file ${callNumber}, '$sourcePath'..." prattle "Page spec is '$pageSpec'." - sourcePath=`escape_chars "$sourcePath"` + sourcePath=$(escape_chars "$sourcePath") PDFJAM_EFFECTIVE_CALL="$0 $callOptions -- $sourcePath $pageSpec" export PDFJAM_EFFECTIVE_CALL PDFJAM_CALL_NUMBER=$callNumber @@ -984,7 +1026,7 @@ if test "$batch" = true ; then eval "$PDFJAM_EFFECTIVE_CALL" ## i.e., call pdfjam again with one input file done - if (test $verbose = true) then cat "$PDFJAM_MESSAGES_FILE" >&2 ; fi + if [ "$verbose" = "true" ]; then cat "$PDFJAM_MESSAGES_FILE" >&2 ; fi IFS=$OIFS exit 0 fi @@ -1010,9 +1052,9 @@ else for k in $fileSpec ; do ## Last substitution on next line is needed for silly characters in ## file names... - sourcePath=`printf "%s" $k | sed 's/|[^|]*$//'` - sourcePath=`escape_chars "$sourcePath"` - pageSpec=`printf "%s" $k | sed 's/.*|//'` + sourcePath=$(printf "%s" $k | sed 's/|[^|]*$//') + sourcePath=$(escape_chars "$sourcePath") + pageSpec=$(printf "%s" $k | sed 's/.*|//') filePageSpec="$filePageSpec$sourcePath $pageSpec " done IFS="$OIFS" @@ -1024,7 +1066,7 @@ prattle "$theCall" 1 ## ######################################################################### ## -## NOW MAKE THE INPUT FILE ETC., READY FOR PDFLATEX +## NOW MAKE THE INPUT FILE ETC., READY FOR LATEX ## filePageList="" ## initialize a string to supply to \includepdfmerge counter=0 @@ -1036,9 +1078,9 @@ stdinUnread=true IFS="$newline" for k in ${fileSpec} do - counter=`expr $counter + 1` - sourcePath=`printf "%s" "$k" | sed 's/|[^|]*$//'` - pageSpec=`printf "%s" $k | sed 's/.*|//'` + counter=$((counter + 1)) + sourcePath=$(printf "%s" "$k" | sed 's/|[^|]*$//') + pageSpec=$(printf "%s" $k | sed 's/.*|//') ## Check, though not exhaustively, for problems with the ## page spec: leading or trailing comma, double comma or ## double dash, alphabetic characters other than the word "last", @@ -1065,22 +1107,26 @@ do fi ;; *) - pdfName=`basename "$sourcePath"` - sourceDir=`dirname "$sourcePath"` ## zsh on Mac OS 10.5 chokes here + pdfName=$(basename "$sourcePath") + sourceDir=$(dirname "$sourcePath") ## zsh on Mac OS 10.5 chokes here cd "$sourceDir" || exit 1 ## just to get the full path - sourceDir=`pwd` + sourceDir=$(pwd) cd "$pwd" || exit 1 sourceFullPath="$sourceDir"/"$pdfName" uniqueName="source-$counter.pdf" uniqueName="$PDFJAM_TEMP_DIR"/"$uniqueName" - ln -s "$sourceFullPath" "$uniqueName" + ## Next is from the Cygwin patch contributed by Lucas + case $(uname) in + *CYGWIN*) cp "$sourceFullPath" "$uniqueName";; + *) ln -s "$sourceFullPath" "$uniqueName";; + esac ;; esac filePageList="$filePageList","$uniqueName","$pageSpec" done IFS="$OIFS" -filePageList=`printf "%s" "$filePageList" | \ - sed 's/^,//'` ## remove leading comma +filePageList=$(printf "%s" "$filePageList" | \ + sed 's/^,//') ## remove leading comma ## ## Do the pdfinfo stuff (if relevant)... ## @@ -1089,19 +1135,19 @@ then if test "$keepinfo" = true then prattle "Calling ${pdfinfo}..." ; - PDFinfo=`pdfinfo "$uniqueName"`; - pdftitl=`printf "%s" "$PDFinfo" | \ - grep -e '^Title:'| sed s/^Title:\\\s\*// | \ - sed -e 's/[#$%^&_{}~]/\\\&/g'`; - pdfauth=`printf "%s" "$PDFinfo" | \ - grep -e '^Author:'| sed s/^Author:\\\s\*// | \ - sed -e 's/[#$%^&_{}~]/\\\&/g'`; - pdfsubj=`printf "%s" "$PDFinfo" | \ - grep -e '^Subject:'| sed s/^Subject:\\\s\*// | \ - sed -e 's/[#$%^&_{}~]/\\\&/g'`; - pdfkeyw=`printf "%s" "$PDFinfo" | \ - grep -e '^Keywords:'| sed s/^Keywords:\\\s\*// | \ - sed -e 's/[#$%^&_{}~]/\\\&/g'`; + PDFinfo=$(pdfinfo "$uniqueName"); + pdftitl=$(printf "%s" "$PDFinfo" | \ + grep -e '^Title:'| 'sed s/^Title:\\\s\*//' | \ + sed -e 's/[#$%^&_{}~]/\\\&/g'); + pdfauth=$(printf "%s" "$PDFinfo" | \ + grep -e '^Author:'| sed 's/^Author:\\\s\*//' | \ + sed -e 's/[#$%^&_{}~]/\\\&/g'); + pdfsubj=$(printf "%s" "$PDFinfo" | \ + grep -e '^Subject:'| sed 's/^Subject:\\\s\*//' | \ + sed -e 's/[#$%^&_{}~]/\\\&/g'); + pdfkeyw=$(printf "%s" "$PDFinfo" | \ + grep -e '^Keywords:'| sed 's/^Keywords:\\\s\*//' | \ + sed -e 's/[#$%^&_{}~]/\\\&/g'); fi if test -n "$pdfTitle" ; then pdftitl="$pdfTitle" @@ -1117,12 +1163,16 @@ then fi fi ## -## Now set up the files for pdflatex... +## Now set up the files for latex... ## fileName="$PDFJAM_TEMP_DIR"/a texFile="$fileName".tex msgFile="$fileName".msgs tempFile="$PDFJAM_TEMP_DIR"/temp.tex +## Next is adapted from the Cygwin patch sent by Lucas +case $(uname) in + *CYGWIN*) filePageList=$(echo "$filePageList" | sed 's~\\~/~g') ;; +esac (cat <<EndTemplate \batchmode \documentclass[$documentOptions]{article} @@ -1135,49 +1185,59 @@ tempFile="$PDFJAM_TEMP_DIR"/temp.tex \hypersetup{pdfsubject={$pdfsubj}} \hypersetup{pdfkeywords={$pdfkeyw}} \usepackage{pdfpages} -$preamble -\begin{document} -\includepdfmerge[$miscOptions]{$filePageList} -\end{document} EndTemplate - ) > $texFile + ) > "$texFile" if test "$hyperref" = false; then ## we don't need hyperref - cp $texFile $tempFile - sed '/\\\usepackage{hyperref}/d' $tempFile | \ + cp "$texFile" "$tempFile" + sed '/\\\usepackage{hyperref}/d' "$tempFile" | \ sed '/\\\hypersetup.*/d' > "${texFile}" - rm $tempFile + rm "$tempFile" fi if test -z "$geometry" ; then geometry=false ; fi if test "$geometry" = false; then ## geometry package is not to be used - cp $texFile $tempFile - cat $tempFile | sed '/\\\usepackage.*{geometry}/d' > $texFile - rm $tempFile + cp "$texFile" "$tempFile" + sed '/\\\usepackage.*{geometry}/d' "$tempFile" > "$texFile" + rm "$tempFile" fi if test -z "$pagecolor"; then ## color package is not needed - cp $texFile $tempFile - cat $tempFile | sed '/\\\usepackage.*{color}/d' > $texFile - rm $tempFile + cp "$texFile" "$tempFile" + sed '/\\\usepackage.*{color}/d' "$tempFile" > "$texFile" + rm "$tempFile" fi +(cat <<EndTemplate +$preamble +\begin{document} +\includepdfmerge[$miscOptions]{$filePageList} +\end{document} +EndTemplate + ) >> "$texFile" ## ## INPUT FILES ARE ALL READY ## ######################################################################### ## -## RUN PDFLATEX AND COPY THE RESULTING PDF FILE +## RUN LATEX AND COPY THE RESULTING PDF FILE ## -prattle "Calling ${pdflatex}..." ; +if [ "$runs" -eq 1 ] ; +then prattle "Calling ${latex}..." +else prattle "Calling ${latex} $runs times..." +fi cd "$PDFJAM_TEMP_DIR" || exit 1 failureText=\ "FAILED. -The call to 'pdflatex' resulted in an error. +The call to $latex resulted in an error. If '--no-tidy' was used, you can examine the log file at $fileName.log to try to diagnose the problem." -$pdflatex $texFile > $msgFile || { - prattle "$failureText" - error_exit "Output file not written" $E_SOFTWARE -} +i=1 +while [ "$i" -le "$runs" ] ; do + $latex "$texFile" > "$msgFile" || { + prattle "$failureText" + error_exit "Run $i: Output file not written" $E_SOFTWARE + } + i=$((i + 1)) +done cd "$pwd" || exit 1 if test -f "$fileName".pdf ## if LaTeX didn't choke then @@ -1192,19 +1252,20 @@ then fi if test ! -w "$outFile" then - prattle "FAILED: no write permission in ${outFile}." - continue + error_exit \ + "FAILED: no write permission on ${outFile}." \ + $E_OSFILE fi separator="-" if test "$pageSpec" != "-" then separator=-"$pageSpec"- fi - outFile=`printf "%s" "$outFile" | sed 's/\/$//'` + outFile=$(printf "%s" "$outFile" | sed 's/\/$//') ## (delete any trailing slash) - pdfName=`basename "$sourcePath"` - pdfName=`printf "%s" "$pdfName" | \ - sed 's/\.[pP][dD][fF]$//'` ## strip extension + pdfName=$(basename "$sourcePath") + pdfName=$(printf "%s" "$pdfName" | \ + sed 's/\.[pP][dD][fF]$//') ## strip extension pdfName="$pdfName$separator$suffix".pdf outFile="$outFile"/"$pdfName" fi @@ -1214,12 +1275,14 @@ if test -f "$outFile" && test ! -w "$outFile" then error_exit "no write permission at ${outFile}" $E_CANTCREATE fi -#fileSize=`wc -c < "$fileName.pdf" | sed 's/^\ *//'` -(cat "$fileName".pdf > "$outFile" 2>/dev/null) && - prattle "Finished. Output was to '${outFile}'." || - error_exit "cannot write output at ${outFile}" $E_CANTCREATE -if (test "$PDFJAM_CALL_NUMBER" = "0") && ## not a secondary call - (test $verbose = true) +#fileSize=$(wc -c < "$fileName.pdf" | sed 's/^\ *//') +if cat "$fileName".pdf > "$outFile" 2>/dev/null +then + prattle "Finished. Output was written to '${outFile}'." +else + error_exit "cannot write output at ${outFile}" $E_CANTCREATE +fi +if [ "$PDFJAM_CALL_NUMBER" = "0" ] && [ "$verbose" = "true" ] then cat "$PDFJAM_MESSAGES_FILE" >&2 fi exit 0 diff --git a/Master/texmf-dist/scripts/pdfjam/pdfjam-pocketmod b/Master/texmf-dist/scripts/pdfjam/pdfjam-pocketmod deleted file mode 100755 index 72efd0e9db9..00000000000 --- a/Master/texmf-dist/scripts/pdfjam/pdfjam-pocketmod +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/sh -## -## pdfjam-pocketmod: A shell program to make an 8-page PDF document -## into an 8-up file with pages ordered and oriented for folding as -## a pocket-sized booklet, as described at http://repocketmod.com/ -## -## Author David Firth (http://go.warwick.ac.uk/dfirth) -## -## This is a simple wrapper for (three runs of) pdfjam, version 2.08 -## -## -## It's hard (?) to set up this particular script to read from /dev/stdin, -## so we'll just insist that the first argument is a file: -## -E_USAGE=64 ## for a command line usage error -for arg -do - case $arg in - --batch) - printf "pdfjam-pocketmod ERROR: the --batch option is not allowed\n" 1>&2 ; - exit "$E_USAGE" ;; - --no-tidy) - n='--no-tidy' ;; - --quiet | -q) - q='-q' ;; - --vanilla) - v='--vanilla' ;; - --checkfiles) - c='--checkfiles' ;; - *) - ;; - esac -done -## -sourceFile="$1" ; -shift ; -## -## Some (very) minimal checking of the first argument: -## -if test ! -f "$sourceFile" ; -then - printf "pdfjam-pocketmod ERROR: first argument must be a PDF file\n" ; - exit $E_USAGE ; -fi -## -## That's all the argument checking! -## -pageSpec="1-8" ## the default page spec -case ${1} in - --* | "") ## no page spec was given - ;; - *) ## a page spec was given, so use it - pageSpec="$1" ; - shift ;; -esac -pdfjam $n $q $c $v -o /dev/stdout "$sourceFile" "$pageSpec" | pdfjam --angle 180 $n $q $v -o /dev/stdout /dev/stdin '1,8,7,6' | pdfjam --nup 4x2 --landscape --frame true "$sourceFile" '2-5' /dev/stdin "$@" - diff --git a/Master/texmf-dist/scripts/pdfjam/pdfjam-slides3up b/Master/texmf-dist/scripts/pdfjam/pdfjam-slides3up deleted file mode 100755 index e41e50a7b96..00000000000 --- a/Master/texmf-dist/scripts/pdfjam/pdfjam-slides3up +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -## -## pdfjam-slides3up: A shell program to make a 3-up "handout" -## of presentation slides, with space for side-notes -## -## Author David Firth (http://go.warwick.ac.uk/dfirth) -## -## This is a simple wrapper for pdfjam, version 2.08 -## -footskip=3.1cm ## default setting -pagecommand='{\thispagestyle{empty}}' ## default setting -case ${1} in - --pagenumbering) - case ${2} in - false) - continue ;; - true) - pagecommand='{\thispagestyle{plain}}' ;; - *) ## a footskip dimension was supplied - pagecommand='{\thispagestyle{plain}}' ; - footskip="$2" ;; - esac ; - shift; shift ;; - *) - continue ;; -esac -exec pdfjam --suffix 3up --nup 1x3 --frame true --noautoscale false \ - --delta "0cm 0.2cm" --scale 0.87 --offset "-3.8cm 0cm" \ - --preamble "\footskip $footskip" --pagecommand "$pagecommand" "$@" diff --git a/Master/texmf-dist/scripts/pdfjam/pdfjam-slides6up b/Master/texmf-dist/scripts/pdfjam/pdfjam-slides6up deleted file mode 100755 index bb65d013379..00000000000 --- a/Master/texmf-dist/scripts/pdfjam/pdfjam-slides6up +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh -## -## pdfjam-slides6up: A shell program to make a 6-up "handout" -## of presentation slides -## -## Author David Firth (http://go.warwick.ac.uk/dfirth) -## -## This is a simple wrapper for pdfjam, version 2.08 -## -footskip=2.7cm ## default setting -pagecommand='{\thispagestyle{empty}}' ## default setting -case ${1} in - --pagenumbering) - case ${2} in - false) - continue ;; - true) - pagecommand='{\thispagestyle{plain}}' ;; - *) ## a footskip dimension was supplied - pagecommand='{\thispagestyle{plain}}' ; - footskip="$2" ;; - esac ; - shift; shift ;; - *) - continue ;; -esac -exec pdfjam --suffix 6up --nup 2x3 --frame true --noautoscale false \ - --delta "0.2cm 0.3cm" --scale 0.95 --preamble "\footskip $footskip" \ - --pagecommand "$pagecommand" "$@" - - diff --git a/Master/texmf-dist/scripts/pdfjam/pdfjoin b/Master/texmf-dist/scripts/pdfjam/pdfjoin deleted file mode 100755 index 923c50d6b6c..00000000000 --- a/Master/texmf-dist/scripts/pdfjam/pdfjoin +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh -## -## pdfjoin: A shell program to concatenate PDF files -## -## Author David Firth (http://go.warwick.ac.uk/dfirth) -## -## This is a simple wrapper for pdfjam, version 2.08 -## -E_USAGE=64 ## for a command line usage error -for arg -do - case $arg in - --batch) - printf "pdfjoin ERROR: the --batch option is not allowed\n" 1>&2; - exit "$E_USAGE" ;; - --orient) ## this was allowed in previous versions of pdfjoin - printf "pdfjoin ERROR: the --orient option is not allowed,\n" 1>&2; - printf " use --landscape or --no-landscape to specify\n" 1>&2; - printf " the output page orientation" 1>&2; - exit "$E_USAGE" ;; - *) continue ;; - esac -done -exec pdfjam --fitpaper true --rotateoversize true --suffix joined "$@" - - diff --git a/Master/texmf-dist/scripts/pdfjam/pdfnup b/Master/texmf-dist/scripts/pdfjam/pdfnup deleted file mode 100755 index 9b2a5f4fdac..00000000000 --- a/Master/texmf-dist/scripts/pdfjam/pdfnup +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -## -## pdfnup: A shell program to n-up pages of PDF files -## -## Author David Firth (http://go.warwick.ac.uk/dfirth) -## -## This is a simple wrapper for pdfjam, version 2.08 -## -E_USAGE=64 ## for a command line usage error -for arg -do - case $arg in - --orient) ## this was allowed in previous versions of pdfnup - printf "pdfnup ERROR: the --orient option is not allowed,\n" 1>&2; - printf " use --landscape or --no-landscape to specify\n" 1>&2; - printf " the output page orientation" 1>&2; - exit "$E_USAGE" ;; - --pages) ## this was allowed in previous versions of pdfnup - printf "pdfnup ERROR: the --pages option is not allowed,\n" 1>&2; - printf " see 'pdfjam --help' or http://go.warwick.ac.uk/pdfjam\n" \ - 1>&2; - printf " for page selection examples\n" 1>&2; - exit "$E_USAGE" ;; - *) continue ;; - esac -done -exec pdfjam --suffix nup --nup 2x1 --landscape "$@" - - diff --git a/Master/texmf-dist/scripts/pdfjam/pdfpun b/Master/texmf-dist/scripts/pdfjam/pdfpun deleted file mode 100755 index a49396d950e..00000000000 --- a/Master/texmf-dist/scripts/pdfjam/pdfpun +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/sh -## -## pdfpun: A shell program to n-up pages of a PDF file with -## the n-upped pages ordered from right to left -## -## Author David Firth (http://go.warwick.ac.uk/dfirth) -## -## This is a simple wrapper for (three runs of) pdfjam, version 2.08 -## -## -E_USAGE=64 ## for a command line usage error -## -for arg -do - case $arg in - --batch) - printf "pdfpun ERROR: the --batch option is not allowed\n" 1>&2; - exit "$E_USAGE" ;; - --no-tidy) - n='--no-tidy' ;; - --quiet | -q) - q='-q' ;; - --checkfiles) - c='--checkfiles' ;; - *) continue ;; - esac -done -sourceFile="$1" ; -shift ; -## -## Some (very) minimal checking of the first argument: -## -if test ! -f "$sourceFile" ; -then - printf "pdfpun ERROR: first argument must be a PDF file\n" ; - exit $E_USAGE ; -fi -if test "$sourceFile" = /dev/stdin ; -then - if tty -s ; then - printf "pdfpun ERROR: tty is connected to connected to stdin, no PDF file found\n" - exit $E_USAGE ; - fi -fi -## -## That's all the argument checking! -## -pageSpec="-" ## the default -case ${1} in - --* | "") - ;; - *) ## a page spec was given - pageSpec="$1" ; - shift ;; -esac -case ${1} in - --outfile) - outFile="$2" ; - shift; shift ;; - *) - ;; -esac -if test -z "$outFile" ; -then - printf "pdfpun ERROR: no output file specified\n" 1>&2 ; - exit "$E_USAGE" ; -fi -pdfjam --reflect true $n $q $c "$sourceFile" "$pageSpec" -o /dev/stdout | \ - pdfjam --landscape --nup 2x1 "$@" -o /dev/stdout | \ - pdfjam --suffix nup --reflect true --fitpaper true $n $q -o "$outFile" - - - |