texlive[67075] trunk: pdfjam (11may23)

commits+karl at tug.org commits+karl at tug.org
Thu May 11 22:16:36 CEST 2023


Revision: 67075
          http://tug.org/svn/texlive?view=revision&revision=67075
Author:   karl
Date:     2023-05-11 22:16:36 +0200 (Thu, 11 May 2023)
Log Message:
-----------
pdfjam (11may23)

Modified Paths:
--------------
    trunk/Build/source/texk/texlive/linked_scripts/pdfjam/pdfjam
    trunk/Master/texmf-dist/doc/man/man1/pdfjam.1
    trunk/Master/texmf-dist/doc/man/man1/pdfjam.man1.pdf
    trunk/Master/texmf-dist/doc/support/pdfjam/README.md
    trunk/Master/texmf-dist/doc/support/pdfjam/VERSION
    trunk/Master/texmf-dist/doc/support/pdfjam/pdfjam.conf
    trunk/Master/texmf-dist/doc/support/pdfjam/tests.zip
    trunk/Master/texmf-dist/scripts/pdfjam/pdfjam

Added Paths:
-----------
    trunk/Master/texmf-dist/doc/support/pdfjam/pdfjam.orig

Modified: trunk/Build/source/texk/texlive/linked_scripts/pdfjam/pdfjam
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/pdfjam/pdfjam	2023-05-11 20:14:09 UTC (rev 67074)
+++ trunk/Build/source/texk/texlive/linked_scripts/pdfjam/pdfjam	2023-05-11 20:16:36 UTC (rev 67075)
@@ -1,5 +1,5 @@
 #!/bin/sh
-version=3.03
+version=3.04
 #########################################################################
 ##                                                                     ##
 ##  pdfjam: A shell-script interface to the "pdfpages" LaTeX package   ##
@@ -7,7 +7,7 @@
 ##                                                                     ##
 ##  Author: David Firth (http://warwick.ac.uk/dfirth)                  ##
 ##                                                                     ##
-##  Usage: see https://github.com/DavidFirth/pdfjam                    ##
+##  Usage: see https://github.com/rrthomas/pdfjam                      ##
 ##         or "pdfjam --help"                                          ##
 ##                                                                     ##
 ##  Relies on:                                                         ##
@@ -135,6 +135,11 @@
                   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.
+     --longedge
+     --shortedge
+		  Specify the direction in which double-sided pages are
+		  flipped. It may not work correctly in all cases, so if every
+		  other page is rotated 180°, flip this switch.
      --landscape
      --no-landscape
                   Specify landscape page orientation (or not) in the
@@ -180,20 +185,37 @@
      --vanilla
                   Suppress the reading of any site-wide or user-specific
                   configuration files.
+     --enc
+                  Specify a command-line encoding
+                  [Default for you at this site: enc=$enc]
      --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
+                  'pdfpages' package.  See the the pdfpages documentation
+                  (usually 'texdoc pdfpages') for more information.
+                  Here KEY is the name of any of the many options for
+                  '\includepdfmerge', and VALUE is a corresponding value.
+                  Examples:
                       --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)
+                      --booklet true (to reorder the pages in signatures,
+                                      generally useful with --nup)
+                      --signature N (specify the signature size, as the 
+                                     number of original pages in a signature
+                                     in the final document. Caveat: booklet
+                                     is a short form for signature, so if 
+                                     you use booklet true, signature will be
+                                     ignored)
                       --trim '1cm 2cm 1cm 2cm' --clip true
                                     (to trim those amounts from left, bottom,
                                      right and top, respectively, of input 
                                      pages) 
+                      --angle NNN (The angle of rotation in degrees. Angles 
+                                   that are not either 90, 180 or 270 will
+                                   still create straight rectangular pages,
+                                   only the content will be rotated.)
                   etc., etc.  For more information see the manual for
                   the 'pdfpages' package, at
                   http://www.ctan.org/tex-archive/macros/latex/contrib/pdfpages
@@ -211,7 +233,7 @@
 if the '--vanilla' argument is used.)
 
 For more information, including a sample configuration file, see
-https://github.com/DavidFirth/pdfjam.
+https://github.com/rrthomas/pdfjam.
 "
 ##
 ##  END OF HELP TEXT
@@ -303,7 +325,7 @@
 	    if  test $lineCounter -eq 1  &&  test ! -n "${2}" ;
 	    then 
 		if test -w "$PDFJAM_MESSAGES_FILE"
-		then printf "$prefix1$indent %s\n" "$line" 1>/dev/null >> \
+		then printf "$prefix1$indent %s\n" "$line" >> \
                        "$PDFJAM_MESSAGES_FILE"
 		else messages="$messages$prefix1$indent $line$newline"  
                        ## msg file not made yet
@@ -310,7 +332,7 @@
 		fi
 	    else 
 		if test -w "$PDFJAM_MESSAGES_FILE"
-		then printf "$prefix2$indent %s\n" "$line" 1>/dev/null >> \
+		then printf "$prefix2$indent %s\n" "$line" >> \
                        "$PDFJAM_MESSAGES_FILE"
 		else messages="$messages$prefix2$indent $line$newline"  
                        ## msg file not made yet
@@ -342,7 +364,7 @@
 ##  once, the last instance prevails.)
 ##
 ##  An example configuration file can be found at
-##     https://github.com/DavidFirth/pdfjam
+##     https://github.com/rrthomas/pdfjam
 ##
 ##  The path searched for site-wide configuration files can be changed
 ##  by editing the variable 'configpath' at the top of this file.
@@ -353,15 +375,17 @@
 latex=$(command -v pdflatex)
 if [ -z "$latex" ] ; then latex="not found" ; fi
 ##
-##  Likewise for the pdfinfo (only needed for `--keepinfo'):
+##  Likewise for the pdfinfo and iconv (only needed for `--keepinfo'):
 ##
 pdfinfo=$(command -v pdfinfo)
 if [ -z "$pdfinfo" ] ; then pdfinfo="not found"; fi
+iconv=$(command -v iconv)
+if [ -z "$iconv" ] ; then iconv="not found"; fi
 ##
 ##
 ##  Next a permitted location for temporary files on your system:
 ##
-tempfileDir='/var/tmp'   ##  /var/tmp is standard on most unix systems
+tempfileDir=${TMPDIR:-'/tmp'}  ##  /tmp is standard on most unix systems
 ##
 ##
 ##  Default for the output file location:
@@ -371,6 +395,8 @@
 ##
 ##  A few more default settings for pdfjam:
 ##
+shortedge='true'           ## Default paper is rotated shortedge when doing book
+##
 runs=1                     ## Run latex just once
 ##
 tidy='true'                ##  Delete all temporary files at the end
@@ -584,6 +610,14 @@
 			tidy=false ;
 			callOptions="$callOptions --no-tidy" ;
 			;;
+		    --shortedge)
+			shortedge=true ;
+			callOptions="$callOptions --shortedge" ;
+			;;
+		    --longedge)
+			shortedge=false ;
+			callOptions="$callOptions --longedge" ;
+			;;
 		    --keepinfo)
 			keepinfo=true ;
 			callOptions="$callOptions --keepinfo" ;
@@ -681,6 +715,10 @@
 		    --preamble)
 			preamble="$preamble${2}" ;
 			shift ;;
+		    --enc) # command line encoding
+			enc="${2}"
+			callOptions="$callOptions ${1} ${2}"
+			shift ;;
 		    --*)
                         ##  options for \includepdfmerge
 			argName=$(printf "%s" "${1}" | sed 's/^--//');
@@ -815,6 +853,12 @@
     *)
 	twoside="" ;;
 esac
+case $shortedge in
+    true)
+	shortedge="" ;;
+    *)
+	shortedge='\usepackage{everyshi}\makeatletter\EveryShipout{\ifodd\c at page\pdfpageattr{/Rotate 180}\fi}\makeatother' ;;
+esac
 if test "$geometry" != false
 then
 ##  we haven't already found that geometry.sty is missing
@@ -843,7 +887,7 @@
 if test $PDFJAM_CALL_NUMBER -eq 0  ## not a secondary call
 then
     ##  Check whether there's a suitable latex to use:
-    case $latex in
+    case "$latex" in
 	"not found")
 	    error_exit "can't find pdflatex!" $E_UNAVAILABLE
 	    ;;
@@ -868,31 +912,13 @@
     error_exit \
 	"LaTeX package pdfpages.sty is not installed" \
 	$E_UNAVAILABLE
-    (kpsewhich eso-pic.sty >/dev/null) ||
-    error_exit \
-	"LaTeX package eso-pic.sty not installed (see the pdfpages manual)" \
-	$E_UNAVAILABLE
-    (kpsewhich everyshi.sty >/dev/null) ||
-    error_exit \
-	"LaTeX package everyshi.sty not installed (see the pdfpages manual)" \
-	$E_UNAVAILABLE
-    if test "$keepinfo" = true ||
-	test -n "$pdfTitle$pdfSubject$pdfAuthor$pdfKeywords"
-    ##  ie, if hyperref is required
-    then
-	(kpsewhich hyperref.sty >/dev/null) || {
-	    prattle "LaTeX package hyperref.sty is not installed, so any"
-	    prattle "--keepinfo, --pdftitle,--pdfauthor, --pdfsubject or" 1
-	    prattle "--pdfkeywords setting will be ignored." 1
-	    hyperref=false
-	    if test "$batch" = true
-	    then
-		export hyperref   ## for use in any secondary calls
-	    fi
-	}
-    else
-	hyperref=false
-    fi
+
+    for pack in pdflscape eso-pic everyshi atbegshi ; do
+        (kpsewhich $pack.sty >/dev/null) ||
+        error_exit \
+	    "LaTeX package $pack.sty is not installed (see the pdfpages manual)" \
+	    $E_UNAVAILABLE
+    done
     if test "$geometry" = true
     ##  ie, if the 'geometry' package is needed for paper size
     then
@@ -907,38 +933,67 @@
 	}
     fi
 fi
-if test "$hyperref" = false
+if  test "$keepinfo" = true
 then
-    keepinfo=false
-    pdfTitle="" ; pdfAuthor="" ; pdfSubject="" ; pdfKeywords=""
-else
-    if  test "$keepinfo" = true
-    then
-	case $pdfinfo in
-	    "not found")
-		if test $PDFJAM_CALL_NUMBER -eq 0
-		then
-		  prattle \
-		  "The pdfinfo utility was not found, so --keepinfo is ignored."
-		fi
-		keepinfo=false
-		;;
-	    pdfinfo)
-		;;
-	    *)  ## $pdfinfo was set in a configuration file
-		if test ! -x "$pdfinfo"
-		then
-		    if test $PDFJAM_CALL_NUMBER -eq 0
-		    then
-			prattle \
-		     "No pdfinfo utility at $pdfinfo, so --keepinfo is ignored."
-			keepinfo=false
-		    fi
-		fi
-		;;
-	esac
+    case "$pdfinfo" in
+	"not found")
+	  if test $PDFJAM_CALL_NUMBER -eq 0
+	  then
+	    prattle \
+	      "The pdfinfo utility was not found, so --keepinfo is ignored."
+	  fi
+	  keepinfo=false
+	  ;;
+	pdfinfo)
+	  ;;
+	*)  ## $pdfinfo was set in a configuration file
+	  if test ! -x "$pdfinfo"
+	  then
+	    if test $PDFJAM_CALL_NUMBER -eq 0
+	    then
+	      prattle \
+		"No pdfinfo utility at $pdfinfo, so --keepinfo is ignored."
+	      keepinfo=false
+	    fi
+	  fi
+	  ;;
+    esac
+    case "$iconv" in
+	"not found")
+	  if test $PDFJAM_CALL_NUMBER -eq 0
+	  then
+	    prattle \
+	      "The iconv utility was not found, so --keepinfo is ignored."
+	  fi
+	  keepinfo=false
+	  ;;
+	iconv)
+	  ;;
+	*)  ## $iconv was set in a configuration file
+	  if test ! -x "$iconv"
+	  then
+	    if test $PDFJAM_CALL_NUMBER -eq 0
+	    then
+	      prattle \
+		"No iconv utility at $iconv, so --keepinfo is ignored."
+	      keepinfo=false
+	    fi
+	  fi
+	  ;;
+    esac
+fi
+## A function to check if using non-Cygwin "${latex}" from Cygwin
+using_non_cygwin_latex_from_cygwin () {
+    if [ -z "${__cache__using_non_cygwin_latex_from_cygwin}" ]; then
+	if [ "$(uname -o)" = "Cygwin" ] \
+	    && "${latex}" -version | head -1 | grep -qv Cygwin; then
+	    __cache__using_non_cygwin_latex_from_cygwin=0
+	else
+	    __cache__using_non_cygwin_latex_from_cygwin=1
+	fi
     fi
-fi
+    return "${__cache__using_non_cygwin_latex_from_cygwin}"
+}
 ##
 ##  END OF CHECKING THE SETUP
 ##
@@ -988,9 +1043,9 @@
 fi
 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
+if using_non_cygwin_latex_from_cygwin; then
+    PDFJAM_TEMP_DIR=$(cygpath -w "$PDFJAM_TEMP_DIR")
+fi
 ##
 ##  TEMPORARY DIRECTORY ALL DONE
 ##
@@ -1116,10 +1171,11 @@
 	    uniqueName="source-$counter.pdf"
 	    uniqueName="$PDFJAM_TEMP_DIR"/"$uniqueName"
 	    ## Next is from the Cygwin patch contributed by Lucas
-	    case $(uname) in
-		*CYGWIN*) cp "$sourceFullPath" "$uniqueName";;
-		*) ln -s "$sourceFullPath" "$uniqueName";;
-            esac
+	    if using_non_cygwin_latex_from_cygwin; then
+		cp "$sourceFullPath" "$uniqueName"
+	    else
+		ln -s "$sourceFullPath" "$uniqueName"
+	    fi
 	    ;;
     esac
     filePageList="$filePageList","$uniqueName","$pageSpec"
@@ -1130,38 +1186,55 @@
 ##
 ##  Do the pdfinfo stuff (if relevant)...
 ##
-if  test "$hyperref" != false
-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');
+select_pdfinfo () {
+    printf '%s' "$2" | \
+    grep -e "^$1:" | \
+    sed -e 's/^'"$1"':\s*//'
+}
+echo_hex_iconv_utf16be () {
+    printf '%s' "$1" | \
+    "$iconv" -f utf8 -t utf16be | \
+    od -An -v -tx1 | \
+    tr -d '[:space:]'
+}
+echo_pdfinfodata () {
+    if [ -n "$2" ]; then
+	TMPA=$(echo_hex_iconv_utf16be "$2")
+	printf '%s' "/$1 <feff${TMPA}>"
     fi
-    if test -n "$pdfTitle" ; then
-	pdftitl="$pdfTitle"
-    fi
-    if test -n "$pdfAuthor" ; then
-	pdfauth="$pdfAuthor"
-    fi
-    if test -n "$pdfSubject" ; then
-	pdfsubj="$pdfSubject"
-    fi
-    if test -n "$pdfKeywords" ; then
-	pdfkeyw="$pdfKeywords"
-    fi
+}
+
+if test "$keepinfo" = true ; then
+    prattle "Calling ${pdfinfo}..."
+    PDFinfo=$(pdfinfo -enc UTF-8 "$uniqueName")
+    pdftitl=$(select_pdfinfo 'Title'    "$PDFinfo")
+    pdfauth=$(select_pdfinfo 'Author'   "$PDFinfo")
+    pdfsubj=$(select_pdfinfo 'Subject'  "$PDFinfo")
+    pdfkeyw=$(select_pdfinfo 'Keywords' "$PDFinfo")
 fi
+echo_iconv_from_enc () {
+    printf '%s' "$2" | \
+    "$iconv" -f "$1" -t utf8
+}
+if test -n "$pdfTitle" ; then
+    pdftitl=$(echo_iconv_from_enc "$enc" "$pdfTitle")
+fi
+if test -n "$pdfAuthor" ; then
+    pdfauth=$(echo_iconv_from_enc "$enc" "$pdfAuthor")
+fi
+if test -n "$pdfSubject" ; then
+    pdfsubj=$(echo_iconv_from_enc "$enc" "$pdfSubject")
+fi
+if test -n "$pdfKeywords" ; then
+    pdfkeyw=$(echo_iconv_from_enc "$enc" "$pdfKeywords")
+fi
+
+## Converting to PDF string
+raw_pdftitl=$(echo_pdfinfodata 'Title'    "$pdftitl")
+raw_pdfauth=$(echo_pdfinfodata 'Author'   "$pdfauth")
+raw_pdfsubj=$(echo_pdfinfodata 'Subject'  "$pdfsubj")
+raw_pdfkeyw=$(echo_pdfinfodata 'Keywords' "$pdfkeyw")
+
 ##
 ##  Now set up the files for latex...
 ##
@@ -1170,9 +1243,9 @@
 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
+if using_non_cygwin_latex_from_cygwin; then
+    filePageList=$(echo "$filePageList" | sed 's~\\~/~g')
+fi
 (cat <<EndTemplate
 \batchmode
 \documentclass[$documentOptions]{article}
@@ -1179,20 +1252,23 @@
 \usepackage{color} \definecolor{bgclr}{RGB}{$pagecolor} \pagecolor{bgclr}
 \usepackage[$papersize]{geometry}
 \usepackage[utf8]{inputenc}
-\usepackage{hyperref}
-\hypersetup{pdftitle={$pdftitl}}
-\hypersetup{pdfauthor={$pdfauth}}
-\hypersetup{pdfsubject={$pdfsubj}}
-\hypersetup{pdfkeywords={$pdfkeyw}}
+\ifdefined\luatexversion% LuaLaTeX
+  \protected\def\pdfinfo{\pdfextension info}
+\fi
+\ifdefined\XeTeXversion% XeLaTeX
+  \protected\def\pdfinfo#1{\AtBeginDvi{\special{pdf:docinfo << #1 >>}}}
+\fi
+\ifdefined\pdfinfo%
+  \pdfinfo{%
+    $raw_pdftitl %
+    $raw_pdfauth %
+    $raw_pdfsubj %
+    $raw_pdfkeyw %
+  }%
+\fi
 \usepackage{pdfpages}
 EndTemplate
     )  > "$texFile"
-if test "$hyperref" = false; then  ## we don't need hyperref
-    cp "$texFile" "$tempFile"
-    sed '/\\\usepackage{hyperref}/d' "$tempFile" | \
-	sed '/\\\hypersetup.*/d' > "${texFile}"
-    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"
@@ -1206,6 +1282,7 @@
 fi
 (cat <<EndTemplate
 $preamble
+$shortedge
 \begin{document}
 \includepdfmerge[$miscOptions]{$filePageList}
 \end{document}
@@ -1232,7 +1309,7 @@
 to try to diagnose the problem."
 i=1
 while [ "$i" -le "$runs" ] ; do
-    $latex "$texFile" > "$msgFile" || {
+    "$latex" "$texFile" > "$msgFile" || {
         prattle "$failureText"
         error_exit "Run $i: Output file not written" $E_SOFTWARE
     }
@@ -1276,7 +1353,10 @@
     error_exit "no write permission at ${outFile}" $E_CANTCREATE
 fi
 #fileSize=$(wc -c < "$fileName.pdf" | sed 's/^\ *//')
-if cat "$fileName".pdf > "$outFile" 2>/dev/null
+## Avoid explicit output to /dev/stdout.
+if test "$outFile" = "/dev/stdout" \
+   && cat "$fileName".pdf 2> /dev/null \
+   || cat "$fileName".pdf > "$outFile" 2>/dev/null
 then
     prattle "Finished.  Output was written to '${outFile}'."
 else

Modified: trunk/Master/texmf-dist/doc/man/man1/pdfjam.1
===================================================================
--- trunk/Master/texmf-dist/doc/man/man1/pdfjam.1	2023-05-11 20:14:09 UTC (rev 67074)
+++ trunk/Master/texmf-dist/doc/man/man1/pdfjam.1	2023-05-11 20:16:36 UTC (rev 67075)
@@ -16,11 +16,11 @@
 the pdfpages package, is required\&.
 .PP 
 The pdfjam script is distributed as (the main) part of the pdfjam package.  The homepage of pdfjam is at
-https://github.com/DavidFirth/pdfjam \&.
+https://github.com/rrthomas/pdfjam \&.
 .PP
 .SH "SETUP" 
 .PP
-See https://github.com/DavidFirth/pdfjam
+See https://github.com/rrthomas/pdfjam
 .PP
 .SH "CONFIGURATION FILES"
 .PP
@@ -42,13 +42,12 @@
 preserve hyperlinks.
 .PP 
 Please report bugs! --- either at GitHub or by email, see
-https://github.com/DavidFirth/pdfjam \&.
+https://github.com/rrthomas/pdfjam \&.
 .PP 
 .SH "LICENSE" 
 .PP 
-pdfjam is distributed under the GNU public license\&.  
+pdfjam is distributed under the GNU public license.  
 .PP 
 .SH "AUTHOR" 
 .PP 
-The pdfjam package is written and maintained by David Firth\&.
-
+The pdfjam package was written by David Firth and is maintained by Reuben Thomas.

Modified: trunk/Master/texmf-dist/doc/man/man1/pdfjam.man1.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/support/pdfjam/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/support/pdfjam/README.md	2023-05-11 20:14:09 UTC (rev 67074)
+++ trunk/Master/texmf-dist/doc/support/pdfjam/README.md	2023-05-11 20:16:36 UTC (rev 67075)
@@ -1,11 +1,11 @@
-[![](https://travis-ci.com/DavidFirth/pdfjam.svg?branch=master)](https://travis-ci.com/DavidFirth/pdfjam)
+[![](https://travis-ci.com/rrthomas/pdfjam.svg?branch=master)](https://travis-ci.com/rrthomas/pdfjam)
 # pdfjam
 
-_David Firth_ <https://warwick.ac.uk/dfirth>
+_Reuben Thomas_ <https://rrt.sc3d.org/>
 
 A snapshot of this page is included as _README.md_ 
 in the distributed package.  The most up-to-date version is maintained online at 
-<https://github.com/DavidFirth/pdfjam>.
+<https://github.com/rrthomas/pdfjam>.
 
 1. [Overview](#overview)
     - [What is pdfjam?](#whatis)
@@ -65,7 +65,7 @@
 
 Those 'wrapper' scripts are **no longer maintained**. I continue to make 
 them available in a separate repository 
-<https://github.com/DavidFirth/pdfjam-extras>, 
+<https://github.com/rrthomas/pdfjam-extras>, 
 in case anyone wants to see them, to use them, or to improve and maintain 
 them independently as a separate project.
 
@@ -81,7 +81,7 @@
 - `pdfjam-slides3up`, `pdfjam-slides6up`
 
 For those scripts and for more information on them, please now see 
-<https://github.com/DavidFirth/pdfjam-extras>.
+<https://github.com/rrthomas/pdfjam-extras>.
 
 
 # <a name="prereq"> Pre-requisites
@@ -120,7 +120,7 @@
 
 In case you want to look at the `pdfjam --help` text template online, for example
 before you decide whether to install **pdfjam**, the source is available at
-<https://github.com/DavidFirth/pdfjam/blob/master/pdfjam-help.txt>.
+<https://github.com/rrthomas/pdfjam/blob/master/pdfjam-help.txt>.
 
 There is also a (very basic) `man` page, accessed in the usual way
 (after installation) by
@@ -143,7 +143,7 @@
 2.  Install it yourself (e.g., if you don't want _TeX Live_, or if you want a later
 release of **pdfjam** than the one that's currently in _TeX Live_). 
 Download the latest packaged release of **pdfjam** from
-<https://github.com/DavidFirth/pdfjam/releases>.
+<https://github.com/rrthomas/pdfjam/releases>.
 If for some reason you don't want the latest released version, or even a recently released version, you can still get older versions too: see <https://davidfirth.github.io/pdfjam>.
 
 **The first way, via _TeX Live_, is recommended** as the easiest way for most users.
@@ -172,7 +172,7 @@
 or some other reason.
 
 The file 
-[pdfjam.conf](https://github.com/DavidFirth/pdfjam/raw/master/pdfjam.conf)
+[pdfjam.conf](https://github.com/rrthomas/pdfjam/raw/master/pdfjam.conf)
 is a sample configuration file which can be edited as needed.  After editing, 
 either install the file for site-wide use (at `/etc/pdfjam.conf`, 
 `/usr/share/etc/pdfjam.conf`, `/usr/local/share/pdfjam.conf`, or 
@@ -291,7 +291,7 @@
 Slides made by LaTeX's _beamer_ package, using the `handout` class option, 
 work especially nicely with this! The example wrapper scripts `pdfjam-slides3up`
 and `pdfjam-slides6up`, in the 
-[pdfjam-extras](https://github.com/DavidFirth/pdfjam-extras) repository,
+[pdfjam-extras](https://github.com/rrthomas/pdfjam-extras) repository,
 are for 3-up and 6-up handouts, respectively.
 
 ### Example 6: Trimming pages; and piped output
@@ -368,7 +368,7 @@
 is up to date. If the problem persists even with up-to-date versions of pdfTeX, 
 `pdftex.def` and pdfpages, then please do report it. 
 
-**2. What can I do to solve a 'Too many open files' error?
+**2. What can I do to solve a 'Too many open files' error?**
 
 This error has been reported to occur sometimes, when dealing with large numbers of 
 documents/pages. A suggested solution, if this happens, 
@@ -386,7 +386,7 @@
 
 Please report any bugs found in `pdfjam`, either
 
-- by reporting as an issue at GitHub, <https://github.com/DavidFirth/pdfjam/issues>
+- by reporting as an issue at GitHub, <https://github.com/rrthomas/pdfjam/issues>
 - by email (see <https://warwick.ac.uk/dfirth> for my email address)
 
 ### Some known problems:
@@ -430,20 +430,27 @@
 And maybe even someone else will 
 want to take on the task of improving and maintaining some of them,
 who knows?  The wrapper scripts (**no longer maintained**) can now be found at 
-<https://github.com/DavidFirth/pdfjam-extras>.
+<https://github.com/rrthomas/pdfjam-extras>.
  
 ### Version release notes
 
-[**3.03**](https://github.com/DavidFirth/pdfjam/releases/tag/v3.03) [2019-11-18]:
+[**3.04**](https://github.com/rrthomas/pdfjam/releases/tag/v3.04) [2023-05-07]:
 
+- Many documentation improvements.
+- Various minor code fixes.
+- No longer depend on hyperref package.
+- Support TMPDIR.
+
+[**3.03**](https://github.com/rrthomas/pdfjam/releases/tag/v3.03) [2019-11-18]:
+
 - Built package now (again) has tests in a zip archive. (needed for CTAN)
 
-[**3.02**](https://github.com/DavidFirth/pdfjam/releases/tag/v3.02) [2019-11-14]: 
+[**3.02**](https://github.com/rrthomas/pdfjam/releases/tag/v3.02) [2019-11-14]: 
 
 - Re-styled the package name to **pdfjam**. (Previously the package --- which then
   contained several scripts --- was named PDFjam).
 - Moved everything to a new home on the web at 
-  <a href="https://github.com/DavidFirth">github.com/DavidFirth</a>.
+  <a href="https://github.com/rrthomas">github.com/rrthomas</a>.
 - Simplified the package by removal of all the 'wrapper' scripts 
   (`pdfnup`, `pdfjoin`, etc.).
 - Settings specified via `--preamble` are now protected from the normal 

Modified: trunk/Master/texmf-dist/doc/support/pdfjam/VERSION
===================================================================
--- trunk/Master/texmf-dist/doc/support/pdfjam/VERSION	2023-05-11 20:14:09 UTC (rev 67074)
+++ trunk/Master/texmf-dist/doc/support/pdfjam/VERSION	2023-05-11 20:16:36 UTC (rev 67075)
@@ -1 +1 @@
-This is pdfjam 3.03
\ No newline at end of file
+This is pdfjam 3.04
\ No newline at end of file

Modified: trunk/Master/texmf-dist/doc/support/pdfjam/pdfjam.conf
===================================================================
--- trunk/Master/texmf-dist/doc/support/pdfjam/pdfjam.conf	2023-05-11 20:14:09 UTC (rev 67074)
+++ trunk/Master/texmf-dist/doc/support/pdfjam/pdfjam.conf	2023-05-11 20:16:36 UTC (rev 67075)
@@ -14,7 +14,7 @@
 ##
 ##  See 'pdfjam --help' for details, including where to put 
 ##  your edited version of this file; or see the file README.md at
-##    https://github.com/DavidFirth/pdfjam
+##    https://github.com/rrthomas/pdfjam
 ##
 ###############################################################
 ##
@@ -46,7 +46,8 @@
 ##
 ##  USE OF THE 'PDFINFO' UTILITY
 ##
-##  Specify whether pdfjam should, by default, try to run 'pdfinfo'
+##  Specify whether pdfjam and iconv (resp.) should, by default,
+##  try to run 'pdfinfo' and 'iconv' (resp.)
 ##  to preserve source document information in the output:
 keepinfo='false'   ## overridden by '--keepinfo' in the call
 # keepinfo='true'  ## the alternative
@@ -55,6 +56,10 @@
 # pdfinfo='/usr/bin/pdfinfo'        ## typical unix system
 # pdfinfo='/opt/local/bin/pdfinfo'  ## Mac OS X with MacPorts
 ##
+##  Specify the 'iconv' program to be used (if any):
+# iconv='/usr/bin/iconv'        ## typical unix system
+# iconv='/opt/local/bin/iconv'  ## Mac OS X with MacPorts
+##
 ###############################################################
 ##
 ##  USE OF 'file -Lb MYFILE' TO CHECK WHETHER A FILE IS A PDF FILE
@@ -95,5 +100,8 @@
 ##
 preamble=''         ## concatenate other strings to this by using '--preamble'
 ##
+# enc='utf8'        ## overridden by '--enc ENC' in the call
+#                   ## ENC must be one of iconv encodings
+##
 ###############################################################
 ##  END OF FILE: that's all you can configure here!

Added: trunk/Master/texmf-dist/doc/support/pdfjam/pdfjam.orig
===================================================================
--- trunk/Master/texmf-dist/doc/support/pdfjam/pdfjam.orig	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/support/pdfjam/pdfjam.orig	2023-05-11 20:16:36 UTC (rev 67075)
@@ -0,0 +1,1171 @@
+#!/bin/sh
+version=N.NN
+#########################################################################
+##                                                                     ##
+##  pdfjam: A shell-script interface to the "pdfpages" LaTeX package   ##
+##  ------                                                             ##
+##                                                                     ##
+##  Author: David Firth (http://warwick.ac.uk/dfirth)                  ##
+##                                                                     ##
+##  Usage: see https://github.com/rrthomas/pdfjam                      ##
+##         or "pdfjam --help"                                          ##
+##                                                                     ##
+##  Relies on:                                                         ##
+##  -- pdflatex (or xelatex or lualatex)                               ##
+##  -- the 'pdfpages' package for LaTeX (ideally version >= 0.4f)      ##
+##                                                                     ##
+##  License: GPL version 2 or later.  This software comes with         ##
+##  ABSOLUTELY NO WARRANTY of fitness for any purpose at all; if you   ##
+##  do not accept that, then you must not use it.                      ##
+##                                                                     ##
+##  The path searched for site-wide configuration files can be set     ##
+##  by editing the following variable:                                 ##
+##                                                                     ##
+    configpath='/etc:/usr/share/etc:/usr/local/share:/usr/local/etc'   ##
+##                                                                     ##
+##  Nothing else in this file should need to be changed.               ##
+##                                                                     ##
+#########################################################################
+##
+##  HELP TEXT
+##
+##  Defines the output of 'pdfjam --help'
+##
+helptext="
+insert contents of pdfjam-help.txt here
+"
+##
+##  END OF HELP TEXT
+##
+#########################################################################
+##
+##  PRELIMINARIES
+##
+##  First determine:
+##    --- whether verbose commentary should be provided (not if --quiet 
+#         or --configpath was specified); 
+##    --- whether this call to pdfjam is a "batch" call; 
+##    --- whether just the help text is required; 
+##    --- or whether all configuration files should be ignored.
+##
+verbose=true
+for arg
+do
+    case $arg in
+	--quiet | -q | --configpath)
+	    verbose=false ;
+	    ;;
+	--version | -V)
+	    echo "$version"
+	    exit 0 ;
+	    ;;
+	--batch)
+	    batch=true ;
+	    ;;
+	--help | -u | -h)
+		printf "%s\n" "$helptext" ;
+		exit 0 ;
+	    ;;
+	--vanilla)
+	    vanilla=true ;
+	    ;;
+	*)
+	    ;;
+    esac
+done
+##
+##  Check to see whether this is a "secondary" call to pdfjam:
+##
+if test -z "$PDFJAM_CALL_NUMBER"  ## not a secondary call
+then
+    PDFJAM_CALL_NUMBER=0
+fi
+##
+##  Keep a copy of the internal file separator, so we can change it safely
+##
+OIFS="$IFS"
+##
+##  Record the full filename of the current working diractory
+##
+pwd=$(pwd)
+##
+##  Trap interrupts so that they kill everything:
+##
+trap 'IFS=$OIFS; exit 1' 1 2 15
+##
+##  The following will be useful for readability of the script:
+##
+newline='
+'
+##
+##  Define a function to escape tricky characters in file names etc:
+##
+escape_chars () {
+    (printf "%s" "${1}" | sed 's/[^a-zA-Z0-9._/\-]/\\&/g')
+}
+##
+##  Define a function to output verbose comments:
+##
+prattle () { ## second argument here is non-null for continuation lines
+    if test $verbose = true; then
+	prefix1="  pdfjam:" ;
+	prefix2=$(printf "%s" "$prefix1" | sed 's/pdfjam:/       /') ;
+	indent="" ;
+	if test "$PDFJAM_CALL_NUMBER" -gt 0  &&
+	    test "$batch" != true
+	then
+	    indent="    "
+	fi
+	IFS="$newline" ;
+	lineCounter=0 ;
+	for line in ${1}
+	do
+	    lineCounter=$((lineCounter + 1)) ;
+	    if  test $lineCounter -eq 1  &&  test ! -n "${2}" ;
+	    then 
+		if test -w "$PDFJAM_MESSAGES_FILE"
+		then printf "$prefix1$indent %s\n" "$line" >> \
+                       "$PDFJAM_MESSAGES_FILE"
+		else messages="$messages$prefix1$indent $line$newline"  
+                       ## msg file not made yet
+		fi
+	    else 
+		if test -w "$PDFJAM_MESSAGES_FILE"
+		then printf "$prefix2$indent %s\n" "$line" >> \
+                       "$PDFJAM_MESSAGES_FILE"
+		else messages="$messages$prefix2$indent $line$newline"  
+                       ## msg file not made yet
+		fi
+	    fi ;
+	done ;
+	IFS="$OIFS" ;
+    fi ;
+    return ;
+}
+##
+##  And here's the first piece of verbose commentary:
+##
+prattle "----" 1
+prattle "This is pdfjam version ${version}."
+##
+#########################################################################
+##
+##  CONFIGURATION
+##
+##  THESE SETTINGS WILL BE OVER-RIDDEN by any found in configuration
+##  files.  By default such files are found at any or all of
+##     /etc/pdfjam.conf
+##     /usr/share/etc/pdfjam.conf
+##     /usr/local/share/pdfjam.conf
+##     /usr/local/etc/pdfjam.conf
+##     $HOME/.pdfjam.conf
+##  (And they are read in that order; if a setting is made more than
+##  once, the last instance prevails.)
+##
+##  An example configuration file can be found at
+##     https://github.com/rrthomas/pdfjam
+##
+##  The path searched for site-wide configuration files can be changed
+##  by editing the variable 'configpath' at the top of this file.
+##
+##
+##  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 and iconv (only needed for `--keepinfo'):
+##
+pdfinfo=$(command -v pdfinfo)
+if [ -z "$pdfinfo" ] ; then pdfinfo="not found"; fi
+iconv=$(command -v iconv)
+if [ -z "$iconv" ] ; then iconv="not found"; fi
+##
+##
+##  Next a permitted location for temporary files on your system:
+##
+tempfileDir='/var/tmp'   ##  /var/tmp is standard on most unix systems
+##
+##
+##  Default for the output file location:
+##
+outFile="$pwd"           ##  Output to the current working directory
+##
+##
+##  A few more default settings for pdfjam:
+##
+shortedge='true'           ## Default paper is rotated shortedge when doing book
+##
+runs=1                     ## Run latex just once
+##
+tidy='true'                ##  Delete all temporary files at the end
+##
+keepinfo='false'           ##  Don't try to preserve "pdfinfo" data
+##
+checkfiles='false'         ##  Don't use the Unix 'file -Lb' utility to
+##                           identify PDF files from their contents;
+##                           rely on the .pdf or .PDF extension instead.
+##
+suffix='pdfjam'            ##  Default filename suffix to be used when 
+##                           --outfile is either (a) a directory, or (b) 
+##                           not specified in a --batch call.
+##
+preamble=''                ##  Default LaTeX preamble string.
+##
+##  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
+##
+##  Now read the site's or user's configuration file(s) if such exist,
+##  unless '--vanilla' was specified.
+##
+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="${configFiles}:$HOME/.pdfjam.conf"
+	PDFJAM_CONFIG=""
+	prattle "Reading any site-wide or user-specific defaults..."
+	IFS=':'
+	for d in $configFiles
+	do
+	    if test -f "$d"; then
+		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/^/    /')
+	if test "$batch" = true ; then export PDFJAM_CONFIG ; fi
+	if test -z "$PDFJAM_CONFIG"
+	then
+	    prattle "(none found)" 1
+	else
+	    prattle "$PDFJAM_CONFIG" 1
+	fi
+    fi
+    if test -n "$PDFJAM_CONFIG" ; then eval "$PDFJAM_CONFIG" ; fi
+else
+    if test $PDFJAM_CALL_NUMBER -eq 0
+    then
+	prattle "Called with '--vanilla': no user or site configuration"
+	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
+##
+#########################################################################
+##
+##  ERROR CODES
+##
+E_USAGE=64           #  command line usage 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 [ -r "$PDFJAM_MESSAGES_FILE" ]
+    then cat "$PDFJAM_MESSAGES_FILE" >&2
+    else printf "%s" "$messages" 1>&2
+    fi
+    printf "  pdfjam ERROR: %s\n" "$1" 1>&2 ;
+    exit "$2" ;
+}
+##
+#########################################################################
+##
+##  READ AND PROCESS THE ARGUMENTS
+##
+##  In case of NO argument supplied, mention 'pdfjam --help':
+##
+if  test $# -eq 0
+then
+    prattle "No arguments supplied; continuing anyway. (See"
+    prattle "'pdfjam --help' for information on usage.)"  1
+fi
+##
+##  Now do the argument loop.
+##
+fileSpec=""
+miscOptions=""
+callOptions=""
+optionsFinished=""
+##
+##  First note any '--checkfiles' or '--no-checkfiles' option
+##
+for arg 
+do
+    case $arg in
+	--checkfiles)
+	    checkfiles=true ;
+	    callOptions="$callOptions --checkfiles" ;
+	    ;;
+	--no-checkfiles)
+	    checkfiles=false ;
+	    callOptions="$callOptions --no-checkfiles" ;
+	    ;;
+    esac
+done
+while test -n "${1}${2}"; do
+    argUnmatched=""
+    if test "$optionsFinished" != true
+    then
+	case ${1} in
+	    --) ## signals end of command-line options
+		optionsFinished=true ;
+		shift ;
+		continue ;
+		;;
+	    --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')
+		    pageSpecAwaited=false
+		fi
+		case ${1} in
+		    --latex)
+			latex="${2}" ;
+			callOptions="$callOptions --latex ${2}" ;
+			shift ;;
+		    --batch)
+			batch=true ;
+			;;
+		    --vanilla)
+			callOptions="$callOptions ${1}" ;
+			;;
+		    --quiet | -q)
+			verbose=false ;
+			callOptions="$callOptions ${1}" ;
+			;;
+		    --outfile | -o)
+			outFile="${2}" ;
+			if test "$batch" = true
+			then
+			    outFile=$(escape_chars "$outFile")
+			fi
+			callOptions="$callOptions --outfile $outFile" ;
+  			shift ;;
+		    --suffix)
+			if test -n "${2}"
+			then
+			    suffix="${2}" ;
+			    if test "$batch" = true
+			    then
+				suffix=$(escape_chars "$suffix")
+			    fi
+			    callOptions="$callOptions --suffix $suffix"
+			    shift
+			else
+			    error_exit \
+				"'--suffix' string has zero length" \
+				$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" ;
+			;;
+		    --no-tidy)
+			tidy=false ;
+			callOptions="$callOptions --no-tidy" ;
+			;;
+		    --shortedge)
+			shortedge=true ;
+			callOptions="$callOptions --shortedge" ;
+			;;
+		    --longedge)
+			shortedge=false ;
+			callOptions="$callOptions --longedge" ;
+			;;
+		    --keepinfo)
+			keepinfo=true ;
+			callOptions="$callOptions --keepinfo" ;
+			;;
+		    --no-keepinfo)
+			keepinfo=false ;
+			callOptions="$callOptions --no-keepinfo" ;
+			;; 
+		    --checkfiles)
+			;; ## already done above
+		    --no-checkfiles)
+			;; ## already done above
+		    --pdftitle)
+			pdfTitle="${2}" ;
+			if test "$batch" = true
+			then
+			    pdfTitle=$(escape_chars "$pdfTitle")
+			fi
+			callOptions="$callOptions --pdftitle $pdfTitle" ;
+			shift ;;
+		    --pdfauthor)
+			pdfAuthor="${2}" ;
+			if test "$batch" = true
+			then
+			    pdfAuthor=$(escape_chars "$pdfAuthor")
+			fi
+			callOptions="$callOptions --pdfauthor $pdfAuthor" ;
+			shift ;;
+		    --pdfsubject)
+			pdfSubject="${2}" ;
+			if test "$batch" = true
+			then
+			    pdfSubject=$(escape_chars "$pdfSubject")
+			fi
+			callOptions="$callOptions --pdfsubject $pdfSubject" ;
+			shift ;;
+		    --pdfkeywords)
+			pdfKeywords="${2}" ;
+			if test "$batch" = true
+			then
+			    pdfKeywords=$(escape_chars "$pdfKeywords")
+			fi
+			callOptions="$callOptions --pdfkeywords $pdfKeywords" ;
+			shift ;;
+		    --paper)
+			paper="${2}"
+			callOptions="$callOptions ${1} ${2}" ;
+			shift ;;
+		    --pagecolor)
+			pagecolor="${2}" ;
+			callOptions="$callOptions ${1} ${2}" ;
+			shift ;;
+                    --a4paper | --a5paper | --b5paper | --letterpaper | \
+                        --executivepaper | --legalpaper)
+			##  standard LaTeX paper sizes
+			paper=$(printf "%s" "${1}" | sed 's/^--//') ;
+			callOptions="$callOptions ${1}" ;
+			;;
+		    --a0paper | --a1paper | --a2paper | --a3paper | \
+                        --a6paper | --b0paper | --b1paper | --b2paper | \
+			--b3paper | --b4paper | --b6paper)
+			##  the 'geometry' package is needed
+			if test "$geometry" != false ;
+			then
+			    paper=$(printf "%s" "${1}" | sed 's/^--//') ;
+			    callOptions="$callOptions ${1}" ;
+			    geometry=true ;
+			fi ;
+			;;
+		    --papersize)
+			##  the 'geometry' package is needed
+			if test "$geometry" != false ;
+			then
+			    papersize="papersize=${2}" ;
+			    callOptions="$callOptions ${1} '${2}'" ;
+			    geometry=true ;
+			fi ;
+			shift ;;
+		    --landscape)
+			landscape=true ;
+			callOptions="$callOptions --landscape" ;
+			;;
+		    --no-landscape)
+			landscape=false ;
+			callOptions="$callOptions --no-landscape" ;
+			;;
+		    --twoside)
+			twoside=true ;
+			callOptions="$callOptions --twoside" ;
+			;;
+		    --no-twoside)
+			twoside=false ;
+			callOptions="$callOptions --no-twoside" ;
+			;;
+		    --preamble)
+			preamble="$preamble${2}" ;
+			shift ;;
+		    --enc) # command line encoding
+			enc="${2}"
+			callOptions="$callOptions ${1} ${2}"
+			shift ;;
+		    --*)
+                        ##  options for \includepdfmerge
+			argName=$(printf "%s" "${1}" | sed 's/^--//');
+			value="${2}"
+			miscOptions=$miscOptions,"$argName=$value" ;
+		        ## saved for possible use in LaTeX file
+			callOptions="$callOptions ${1} '$value'" ;
+		        ## saved for possible use in a further call to pdfjam
+			shift ;
+			;;
+		esac ;;
+	    '' | *)
+		argUnmatched=true
+		;;
+	esac
+    fi
+    if test "$optionsFinished" = true  ||  test "$argUnmatched" = true
+    then
+	case ${1} in
+	    "" | /dev/stdin)
+		fileSpec="${fileSpec}${newline}/dev/stdin|awaited"
+		pageSpecAwaited=true
+		inputFromStdin=true ;;
+	    -)
+		if test "$pageSpecAwaited" = true  ; then
+		    fileSpec=$(printf "%s" "$fileSpec" | \
+			sed 's/|awaited/|-/g')
+		    pageSpecAwaited=false
+		else
+		    error_exit "no PDF/JPG/PNG file found at ${1}" \
+			$E_NOINPUT
+		fi ;;
+	    *)  ##  All other args should be PDF (or JPG/PNG) 
+                ##  source files and page selections; if not, we'll quit
+		if test "$checkfiles" = true ;  ## not always available
+		then
+		    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"
+			    pageSpecAwaited=true
+			    ;;
+			*)
+			    case ${1} in
+				*.[pP][dD][fF] | *.[jJ][pP][eE][gG] | \
+				    *.[jJ][pP][gG] | *.[pP][nN][gG]) 
+                                    ## should be PDF/JPG/PNG file, but isn't
+				    error_exit "no PDF/JPG/PNG file found at ${1}" \
+					$E_NOINPUT
+				    ;;
+				*) ##  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")
+					pageSpecAwaited=false
+				    else
+					error_exit "no PDF/JPG/PNG file found at ${1}" \
+					    $E_NOINPUT
+				    fi
+				    ;;
+			    esac
+			    ;;
+		    esac
+		else  ## no checking of file contents; rely on .pdf extension
+		    case ${1} in
+			*.[pP][dD][fF] | *.[jJ][pP][eE][gG] \
+			    | *.[jJ][pP][gG] | *.[pP][nN][gG])  
+                            ## assume it's a PDF/JPG/PNG file
+			    test -f "${1}" || error_exit \
+				"${1} not found" $E_NOINPUT
+			    fileSpec="$fileSpec"$newline${1}"|"awaited
+			    pageSpecAwaited=true
+			    ;;
+			*) ##  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")
+				pageSpecAwaited=false
+			    else
+				error_exit "no PDF/JPG/PNG file found at ${1}" \
+				    $E_NOINPUT
+			    fi
+			    ;;
+		    esac
+		fi
+		;;
+	esac
+    fi
+    shift
+done
+##
+##  Use the default page spec for any that remain unspecified:
+##
+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
+then
+    ## the special argument '/dev/stdin' was not used
+    if test -z "$fileSpec" ; then
+    ## no argument specifying a PDF source was given
+	inputFromStdin=true
+	fileSpec="/dev/stdin|-"
+	prattle "No PDF/JPG/PNG source specified: input is from stdin."
+    fi
+fi
+##
+##  Delete leading comma from $miscOptions:
+##
+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/^ //')
+##
+##  Set up a document options variable:
+##
+case $landscape in
+    true)
+	orientation=landscape ;;
+    *)
+	orientation="" ;;
+esac
+case $twoside in
+    true)
+	twoside=twoside ;;
+    *)
+	twoside="" ;;
+esac
+case $shortedge in
+    true)
+	shortedge="" ;;
+    *)
+	shortedge='\usepackage{everyshi}\makeatletter\EveryShipout{\ifodd\c at page\pdfpageattr{/Rotate 180}\fi}\makeatother' ;;
+esac
+if test "$geometry" != false
+then
+##  we haven't already found that geometry.sty is missing
+    case $paper in
+	a0paper | a1paper | a2paper | a3paper | \
+            a6paper | b0paper | b1paper | b2paper | \
+	    b3paper | b4paper | b6paper)
+	    ##  the 'geometry' package is needed
+	    geometry=true ;
+	    ;;
+	*)
+	    ;;
+    esac
+fi
+documentOptions="$paper","$orientation","$twoside"
+documentOptions=$(printf "%s" "$documentOptions" | sed 's/^,//' | sed 's/,$//')
+##
+##  END OF ARGUMENT PROCESSING
+##
+#########################################################################
+##
+##  CHECK SYSTEM SETUP
+##
+##  These checks are not repeated in secondary calls.
+##
+if test $PDFJAM_CALL_NUMBER -eq 0  ## not a secondary call
+then
+    ##  Check whether there's a suitable latex to use:
+    case "$latex" in
+	"not found")
+	    error_exit "can't find pdflatex!" $E_UNAVAILABLE
+	    ;;
+	*)  ## 
+	    if test ! -x "$latex"
+	    then
+		error_exit \
+		    "configuration error, $latex is not an executable file" \
+		    $E_CONFIG
+	    fi
+	    ;;
+    esac
+    ##
+    ##  Check that necessary LaTeX packages are installed:
+    ##
+    modifyPath=$(printf "%s" "$latex" | sed 's/\/[^\/]*$//')
+    if [ -n "$modifyPath" ] ; then
+	PATH="$modifyPath:$PATH"
+	export PATH
+    fi
+    (kpsewhich pdfpages.sty >/dev/null) ||
+    error_exit \
+	"LaTeX package pdfpages.sty is not installed" \
+	$E_UNAVAILABLE
+
+    for pack in pdflscape eso-pic everyshi atbegshi ; do
+        (kpsewhich $pack.sty >/dev/null) ||
+        error_exit \
+	    "LaTeX package $pack.sty is not installed (see the pdfpages manual)" \
+	    $E_UNAVAILABLE
+    done
+    if test "$geometry" = true
+    ##  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"
+	    prattle "standard LaTeX paper sizes are available." 1
+	    geometry=false
+	    if test "$batch" = true
+	    then
+		export geometry   ## for use in any secondary calls
+	    fi
+	}
+    fi
+fi
+if  test "$keepinfo" = true
+then
+    case "$pdfinfo" in
+	"not found")
+	  if test $PDFJAM_CALL_NUMBER -eq 0
+	  then
+	    prattle \
+	      "The pdfinfo utility was not found, so --keepinfo is ignored."
+	  fi
+	  keepinfo=false
+	  ;;
+	pdfinfo)
+	  ;;
+	*)  ## $pdfinfo was set in a configuration file
+	  if test ! -x "$pdfinfo"
+	  then
+	    if test $PDFJAM_CALL_NUMBER -eq 0
+	    then
+	      prattle \
+		"No pdfinfo utility at $pdfinfo, so --keepinfo is ignored."
+	      keepinfo=false
+	    fi
+	  fi
+	  ;;
+    esac
+    case "$iconv" in
+	"not found")
+	  if test $PDFJAM_CALL_NUMBER -eq 0
+	  then
+	    prattle \
+	      "The iconv utility was not found, so --keepinfo is ignored."
+	  fi
+	  keepinfo=false
+	  ;;
+	iconv)
+	  ;;
+	*)  ## $iconv was set in a configuration file
+	  if test ! -x "$iconv"
+	  then
+	    if test $PDFJAM_CALL_NUMBER -eq 0
+	    then
+	      prattle \
+		"No iconv utility at $iconv, so --keepinfo is ignored."
+	      keepinfo=false
+	    fi
+	  fi
+	  ;;
+    esac
+fi
+## A function to check if using non-Cygwin "${latex}" from Cygwin
+using_non_cygwin_latex_from_cygwin () {
+    if [ -z "${__cache__using_non_cygwin_latex_from_cygwin}" ]; then
+	if [ "$(uname -o)" = "Cygwin" ] \
+	    && "${latex}" -version | head -1 | grep -qv Cygwin; then
+	    __cache__using_non_cygwin_latex_from_cygwin=0
+	else
+	    __cache__using_non_cygwin_latex_from_cygwin=1
+	fi
+    fi
+    return "${__cache__using_non_cygwin_latex_from_cygwin}"
+}
+##
+##  END OF CHECKING THE SETUP
+##
+#########################################################################
+##
+##  TEMPORARY FILES
+##
+##  Make a secure temporary directory (following
+##  the autoconf manual).
+##
+##  Use mktemp if possible; otherwise fall back on mkdir,
+##  with random name to make file collisions less likely.
+##
+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 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) &&
+	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)
+	PDFJAM_TEMP_DIR="$tempfileDir"/pdfjam"$$"-"$random"
+	(umask 077 && mkdir "$PDFJAM_TEMP_DIR")
+    } || exit $?
+##
+    export PDFJAM_TEMP_DIR    ##  so that same dir is used in secondary calls
+    if test $tidy = false ; then
+	prattle "Temporary directory for this job is
+          $PDFJAM_TEMP_DIR"
+    fi
+    PDFJAM_MESSAGES_FILE="$PDFJAM_TEMP_DIR"/messages.txt
+    export PDFJAM_MESSAGES_FILE  
+        ## so that secondary calls can write messages there as well
+    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"
+    (umask 077 && mkdir "$PDFJAM_TEMP_DIR")
+fi
+umask "$original_umask"
+## Next is from the Cygwin patch contributed by Lucas
+if using_non_cygwin_latex_from_cygwin; then
+    PDFJAM_TEMP_DIR=$(cygpath -w "$PDFJAM_TEMP_DIR")
+fi
+##
+##  TEMPORARY DIRECTORY ALL DONE
+##
+#########################################################################
+##
+##  HANDLING THE "--batch" OPTION
+##
+##  If --batch was used, we'll call pdfjam separately on each input
+##  file.
+##
+if test "$batch" = true ; then
+    if test "$fileSpec" = "" ; then
+	error_exit "--batch was used, but no PDF/JPG/PNG source file(s) specified" \
+	    $E_USAGE
+    fi
+    if test "$inputFromStdin" = true ; then
+	error_exit "--batch cannot be used with input from stdin" \
+	    $E_USAGE
+    fi
+    IFS="$newline"
+    for k in $fileSpec ; do
+	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")
+	PDFJAM_EFFECTIVE_CALL="$0 $callOptions -- $sourcePath $pageSpec"
+	export PDFJAM_EFFECTIVE_CALL
+	PDFJAM_CALL_NUMBER=$callNumber
+	export PDFJAM_CALL_NUMBER
+	eval "$PDFJAM_EFFECTIVE_CALL"
+        ## i.e., call pdfjam again with one input file
+    done
+    if [ "$verbose" = "true" ]; then cat "$PDFJAM_MESSAGES_FILE" >&2 ; fi
+    IFS=$OIFS
+    exit 0
+fi
+##
+##  END OF THE '--batch' PROCESSING
+##
+#########################################################################
+##
+##  RECORD THE EFFECTIVE CALL TO PDFJAM, FOR POSSIBLE DEBUGGING PURPOSES
+##
+##  Save the text of this (effective) call to pdfjam in a temporary file,
+##  for later inspection if necessary.
+##
+##  For secondary calls, the effective call text is already made;
+##  otherwise we make it here.
+##
+if test "$PDFJAM_CALL_NUMBER" -gt 0
+then
+    theCall="$PDFJAM_EFFECTIVE_CALL"
+else
+    filePageSpec=""
+    IFS="$newline"
+    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/.*|//')
+	filePageSpec="$filePageSpec$sourcePath $pageSpec "
+    done
+    IFS="$OIFS"
+    theCall="$0 $callOptions -- $filePageSpec"
+fi
+printf "%s\n%s\n" "cd $pwd" "$theCall" > "$PDFJAM_TEMP_DIR"/call.txt
+prattle "Effective call for this run of pdfjam:"
+prattle "$theCall" 1
+##
+#########################################################################
+##
+##  NOW MAKE THE INPUT FILE ETC., READY FOR LATEX
+##
+filePageList=""  ## initialize a string to supply to \includepdfmerge
+counter=0
+##
+##  Make symbolic link(s) to the source file(s) in the temporary dir,
+##  and make the $filePageList string for input to \includepdfmerge
+##
+stdinUnread=true
+IFS="$newline"
+for k in ${fileSpec}
+do
+    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",
+    ##  braces not paired as {} with nothing inbetween.  A fully
+    ##  specified pattern for valid \includepdfmerge page spec would
+    ##  be better here; but life is too short...
+    if printf "%s" "$pageSpec" | sed 's/last/99/g' | \
+	grep  '^,.*\|,$\|,,\|--\|[A-Za-z]\|{[^}]\|[^{]}' 1>/dev/null
+    then
+	error_exit "invalid page spec $pageSpec" $E_USAGE
+    fi
+    case $sourcePath in
+	/dev/stdin)
+	    uniqueName="$PDFJAM_TEMP_DIR"/stdin.pdf
+	    if test "$stdinUnread" = true
+	    then
+		if tty -s ; then
+		    error_exit \
+		 "tty is connected to connected to stdin, no PDF/JPG/PNG file found" \
+			$E_NOINPUT
+		fi
+		cat > "$uniqueName"
+		stdinUnread=false
+	    fi
+	    ;;
+	*)
+	    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)
+	    cd "$pwd" || exit 1
+	    sourceFullPath="$sourceDir"/"$pdfName"
+	    uniqueName="source-$counter.pdf"
+	    uniqueName="$PDFJAM_TEMP_DIR"/"$uniqueName"
+	    ## Next is from the Cygwin patch contributed by Lucas
+	    if using_non_cygwin_latex_from_cygwin; then
+		cp "$sourceFullPath" "$uniqueName"
+	    else
+		ln -s "$sourceFullPath" "$uniqueName"
+	    fi
+	    ;;
+    esac
+    filePageList="$filePageList","$uniqueName","$pageSpec"
+done
+IFS="$OIFS"
+filePageList=$(printf "%s" "$filePageList" | \
+    sed 's/^,//')  ## remove leading comma
+##
+##  Do the pdfinfo stuff (if relevant)...
+##
+select_pdfinfo () {
+    printf '%s' "$2" | \
+    grep -e "^$1:" | \
+    sed -e 's/^'"$1"':\s*//'
+}
+echo_hex_iconv_utf16be () {
+    printf '%s' "$1" | \
+    "$iconv" -f utf8 -t utf16be | \
+    od -An -v -tx1 | \
+    tr -d '[:space:]'
+}
+echo_pdfinfodata () {
+    if [ -n "$2" ]; then
+	TMPA=$(echo_hex_iconv_utf16be "$2")
+	printf '%s' "/$1 <feff${TMPA}>"
+    fi
+}
+
+if test "$keepinfo" = true ; then
+    prattle "Calling ${pdfinfo}..."
+    PDFinfo=$(pdfinfo -enc UTF-8 "$uniqueName")
+    pdftitl=$(select_pdfinfo 'Title'    "$PDFinfo")
+    pdfauth=$(select_pdfinfo 'Author'   "$PDFinfo")
+    pdfsubj=$(select_pdfinfo 'Subject'  "$PDFinfo")
+    pdfkeyw=$(select_pdfinfo 'Keywords' "$PDFinfo")
+fi
+echo_iconv_from_enc () {
+    printf '%s' "$2" | \
+    "$iconv" -f "$1" -t utf8
+}
+if test -n "$pdfTitle" ; then
+    pdftitl=$(echo_iconv_from_enc "$enc" "$pdfTitle")
+fi
+if test -n "$pdfAuthor" ; then
+    pdfauth=$(echo_iconv_from_enc "$enc" "$pdfAuthor")
+fi
+if test -n "$pdfSubject" ; then
+    pdfsubj=$(echo_iconv_from_enc "$enc" "$pdfSubject")
+fi
+if test -n "$pdfKeywords" ; then
+    pdfkeyw=$(echo_iconv_from_enc "$enc" "$pdfKeywords")
+fi
+
+## Converting to PDF string
+raw_pdftitl=$(echo_pdfinfodata 'Title'    "$pdftitl")
+raw_pdfauth=$(echo_pdfinfodata 'Author'   "$pdfauth")
+raw_pdfsubj=$(echo_pdfinfodata 'Subject'  "$pdfsubj")
+raw_pdfkeyw=$(echo_pdfinfodata 'Keywords' "$pdfkeyw")
+
+##
+##  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
+if using_non_cygwin_latex_from_cygwin; then
+    filePageList=$(echo "$filePageList" | sed 's~\\~/~g')
+fi
+(cat <<EndTemplate
+\batchmode
+\documentclass[$documentOptions]{article}
+\usepackage{color} \definecolor{bgclr}{RGB}{$pagecolor} \pagecolor{bgclr}
+\usepackage[$papersize]{geometry}
+\usepackage[utf8]{inputenc}
+\ifdefined\luatexversion% LuaLaTeX
+  \protected\def\pdfinfo{\pdfextension info}
+\fi
+\ifdefined\XeTeXversion% XeLaTeX
+  \protected\def\pdfinfo#1{\AtBeginDvi{\special{pdf:docinfo << #1 >>}}}
+\fi
+\ifdefined\pdfinfo%
+  \pdfinfo{%
+    $raw_pdftitl %
+    $raw_pdfauth %
+    $raw_pdfsubj %
+    $raw_pdfkeyw %
+  }%
+\fi
+\usepackage{pdfpages}
+EndTemplate
+    )  > "$texFile"
+if test -z "$geometry" ; then geometry=false ; fi
+if test "$geometry" = false; then   ## geometry package is not to be used
+    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"
+    sed '/\\\usepackage.*{color}/d' "$tempFile" > "$texFile"
+    rm "$tempFile"
+fi
+(cat <<EndTemplate
+$preamble
+$shortedge
+\begin{document}
+\includepdfmerge[$miscOptions]{$filePageList}
+\end{document}
+EndTemplate
+    )  >> "$texFile"
+##
+##  INPUT FILES ARE ALL READY
+##
+#########################################################################
+##
+##  RUN LATEX AND COPY THE RESULTING PDF FILE 
+##
+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 $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."
+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
+    ##  Checks on output file path:
+    if test -d "$outFile"  ## outfile is a directory
+    then
+	if test "$sourcePath" = /dev/stdin 
+	then
+	    error_exit \
+		"--outfile cannot be a directory when input is stdin" \
+		$E_USAGE
+	fi
+	if test ! -w "$outFile"
+	then
+	    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/\/$//')
+                ## (delete any trailing slash)
+	pdfName=$(basename "$sourcePath")
+	pdfName=$(printf "%s" "$pdfName" | \
+	    sed 's/\.[pP][dD][fF]$//')       ## strip extension
+	pdfName="$pdfName$separator$suffix".pdf
+	outFile="$outFile"/"$pdfName"
+    fi		
+fi
+if  test -f "$outFile"  &&  test ! -w "$outFile"
+    ## file exists and we can't over-write it
+then
+    error_exit "no write permission at ${outFile}" $E_CANTCREATE
+fi
+#fileSize=$(wc -c < "$fileName.pdf" | sed 's/^\ *//')
+## Avoid explicit output to /dev/stdout.
+if test "$outFile" = "/dev/stdout" \
+   && cat "$fileName".pdf 2> /dev/null \
+   || 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
+##
+##  END
+##
+#########################################################################


Property changes on: trunk/Master/texmf-dist/doc/support/pdfjam/pdfjam.orig
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Modified: trunk/Master/texmf-dist/doc/support/pdfjam/tests.zip
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/scripts/pdfjam/pdfjam
===================================================================
--- trunk/Master/texmf-dist/scripts/pdfjam/pdfjam	2023-05-11 20:14:09 UTC (rev 67074)
+++ trunk/Master/texmf-dist/scripts/pdfjam/pdfjam	2023-05-11 20:16:36 UTC (rev 67075)
@@ -1,5 +1,5 @@
 #!/bin/sh
-version=3.03
+version=3.04
 #########################################################################
 ##                                                                     ##
 ##  pdfjam: A shell-script interface to the "pdfpages" LaTeX package   ##
@@ -7,7 +7,7 @@
 ##                                                                     ##
 ##  Author: David Firth (http://warwick.ac.uk/dfirth)                  ##
 ##                                                                     ##
-##  Usage: see https://github.com/DavidFirth/pdfjam                    ##
+##  Usage: see https://github.com/rrthomas/pdfjam                      ##
 ##         or "pdfjam --help"                                          ##
 ##                                                                     ##
 ##  Relies on:                                                         ##
@@ -135,6 +135,11 @@
                   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.
+     --longedge
+     --shortedge
+		  Specify the direction in which double-sided pages are
+		  flipped. It may not work correctly in all cases, so if every
+		  other page is rotated 180°, flip this switch.
      --landscape
      --no-landscape
                   Specify landscape page orientation (or not) in the
@@ -180,20 +185,37 @@
      --vanilla
                   Suppress the reading of any site-wide or user-specific
                   configuration files.
+     --enc
+                  Specify a command-line encoding
+                  [Default for you at this site: enc=$enc]
      --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
+                  'pdfpages' package.  See the the pdfpages documentation
+                  (usually 'texdoc pdfpages') for more information.
+                  Here KEY is the name of any of the many options for
+                  '\includepdfmerge', and VALUE is a corresponding value.
+                  Examples:
                       --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)
+                      --booklet true (to reorder the pages in signatures,
+                                      generally useful with --nup)
+                      --signature N (specify the signature size, as the 
+                                     number of original pages in a signature
+                                     in the final document. Caveat: booklet
+                                     is a short form for signature, so if 
+                                     you use booklet true, signature will be
+                                     ignored)
                       --trim '1cm 2cm 1cm 2cm' --clip true
                                     (to trim those amounts from left, bottom,
                                      right and top, respectively, of input 
                                      pages) 
+                      --angle NNN (The angle of rotation in degrees. Angles 
+                                   that are not either 90, 180 or 270 will
+                                   still create straight rectangular pages,
+                                   only the content will be rotated.)
                   etc., etc.  For more information see the manual for
                   the 'pdfpages' package, at
                   http://www.ctan.org/tex-archive/macros/latex/contrib/pdfpages
@@ -211,7 +233,7 @@
 if the '--vanilla' argument is used.)
 
 For more information, including a sample configuration file, see
-https://github.com/DavidFirth/pdfjam.
+https://github.com/rrthomas/pdfjam.
 "
 ##
 ##  END OF HELP TEXT
@@ -303,7 +325,7 @@
 	    if  test $lineCounter -eq 1  &&  test ! -n "${2}" ;
 	    then 
 		if test -w "$PDFJAM_MESSAGES_FILE"
-		then printf "$prefix1$indent %s\n" "$line" 1>/dev/null >> \
+		then printf "$prefix1$indent %s\n" "$line" >> \
                        "$PDFJAM_MESSAGES_FILE"
 		else messages="$messages$prefix1$indent $line$newline"  
                        ## msg file not made yet
@@ -310,7 +332,7 @@
 		fi
 	    else 
 		if test -w "$PDFJAM_MESSAGES_FILE"
-		then printf "$prefix2$indent %s\n" "$line" 1>/dev/null >> \
+		then printf "$prefix2$indent %s\n" "$line" >> \
                        "$PDFJAM_MESSAGES_FILE"
 		else messages="$messages$prefix2$indent $line$newline"  
                        ## msg file not made yet
@@ -342,7 +364,7 @@
 ##  once, the last instance prevails.)
 ##
 ##  An example configuration file can be found at
-##     https://github.com/DavidFirth/pdfjam
+##     https://github.com/rrthomas/pdfjam
 ##
 ##  The path searched for site-wide configuration files can be changed
 ##  by editing the variable 'configpath' at the top of this file.
@@ -353,15 +375,17 @@
 latex=$(command -v pdflatex)
 if [ -z "$latex" ] ; then latex="not found" ; fi
 ##
-##  Likewise for the pdfinfo (only needed for `--keepinfo'):
+##  Likewise for the pdfinfo and iconv (only needed for `--keepinfo'):
 ##
 pdfinfo=$(command -v pdfinfo)
 if [ -z "$pdfinfo" ] ; then pdfinfo="not found"; fi
+iconv=$(command -v iconv)
+if [ -z "$iconv" ] ; then iconv="not found"; fi
 ##
 ##
 ##  Next a permitted location for temporary files on your system:
 ##
-tempfileDir='/var/tmp'   ##  /var/tmp is standard on most unix systems
+tempfileDir=${TMPDIR:-'/tmp'}  ##  /tmp is standard on most unix systems
 ##
 ##
 ##  Default for the output file location:
@@ -371,6 +395,8 @@
 ##
 ##  A few more default settings for pdfjam:
 ##
+shortedge='true'           ## Default paper is rotated shortedge when doing book
+##
 runs=1                     ## Run latex just once
 ##
 tidy='true'                ##  Delete all temporary files at the end
@@ -584,6 +610,14 @@
 			tidy=false ;
 			callOptions="$callOptions --no-tidy" ;
 			;;
+		    --shortedge)
+			shortedge=true ;
+			callOptions="$callOptions --shortedge" ;
+			;;
+		    --longedge)
+			shortedge=false ;
+			callOptions="$callOptions --longedge" ;
+			;;
 		    --keepinfo)
 			keepinfo=true ;
 			callOptions="$callOptions --keepinfo" ;
@@ -681,6 +715,10 @@
 		    --preamble)
 			preamble="$preamble${2}" ;
 			shift ;;
+		    --enc) # command line encoding
+			enc="${2}"
+			callOptions="$callOptions ${1} ${2}"
+			shift ;;
 		    --*)
                         ##  options for \includepdfmerge
 			argName=$(printf "%s" "${1}" | sed 's/^--//');
@@ -815,6 +853,12 @@
     *)
 	twoside="" ;;
 esac
+case $shortedge in
+    true)
+	shortedge="" ;;
+    *)
+	shortedge='\usepackage{everyshi}\makeatletter\EveryShipout{\ifodd\c at page\pdfpageattr{/Rotate 180}\fi}\makeatother' ;;
+esac
 if test "$geometry" != false
 then
 ##  we haven't already found that geometry.sty is missing
@@ -843,7 +887,7 @@
 if test $PDFJAM_CALL_NUMBER -eq 0  ## not a secondary call
 then
     ##  Check whether there's a suitable latex to use:
-    case $latex in
+    case "$latex" in
 	"not found")
 	    error_exit "can't find pdflatex!" $E_UNAVAILABLE
 	    ;;
@@ -868,31 +912,13 @@
     error_exit \
 	"LaTeX package pdfpages.sty is not installed" \
 	$E_UNAVAILABLE
-    (kpsewhich eso-pic.sty >/dev/null) ||
-    error_exit \
-	"LaTeX package eso-pic.sty not installed (see the pdfpages manual)" \
-	$E_UNAVAILABLE
-    (kpsewhich everyshi.sty >/dev/null) ||
-    error_exit \
-	"LaTeX package everyshi.sty not installed (see the pdfpages manual)" \
-	$E_UNAVAILABLE
-    if test "$keepinfo" = true ||
-	test -n "$pdfTitle$pdfSubject$pdfAuthor$pdfKeywords"
-    ##  ie, if hyperref is required
-    then
-	(kpsewhich hyperref.sty >/dev/null) || {
-	    prattle "LaTeX package hyperref.sty is not installed, so any"
-	    prattle "--keepinfo, --pdftitle,--pdfauthor, --pdfsubject or" 1
-	    prattle "--pdfkeywords setting will be ignored." 1
-	    hyperref=false
-	    if test "$batch" = true
-	    then
-		export hyperref   ## for use in any secondary calls
-	    fi
-	}
-    else
-	hyperref=false
-    fi
+
+    for pack in pdflscape eso-pic everyshi atbegshi ; do
+        (kpsewhich $pack.sty >/dev/null) ||
+        error_exit \
+	    "LaTeX package $pack.sty is not installed (see the pdfpages manual)" \
+	    $E_UNAVAILABLE
+    done
     if test "$geometry" = true
     ##  ie, if the 'geometry' package is needed for paper size
     then
@@ -907,38 +933,67 @@
 	}
     fi
 fi
-if test "$hyperref" = false
+if  test "$keepinfo" = true
 then
-    keepinfo=false
-    pdfTitle="" ; pdfAuthor="" ; pdfSubject="" ; pdfKeywords=""
-else
-    if  test "$keepinfo" = true
-    then
-	case $pdfinfo in
-	    "not found")
-		if test $PDFJAM_CALL_NUMBER -eq 0
-		then
-		  prattle \
-		  "The pdfinfo utility was not found, so --keepinfo is ignored."
-		fi
-		keepinfo=false
-		;;
-	    pdfinfo)
-		;;
-	    *)  ## $pdfinfo was set in a configuration file
-		if test ! -x "$pdfinfo"
-		then
-		    if test $PDFJAM_CALL_NUMBER -eq 0
-		    then
-			prattle \
-		     "No pdfinfo utility at $pdfinfo, so --keepinfo is ignored."
-			keepinfo=false
-		    fi
-		fi
-		;;
-	esac
+    case "$pdfinfo" in
+	"not found")
+	  if test $PDFJAM_CALL_NUMBER -eq 0
+	  then
+	    prattle \
+	      "The pdfinfo utility was not found, so --keepinfo is ignored."
+	  fi
+	  keepinfo=false
+	  ;;
+	pdfinfo)
+	  ;;
+	*)  ## $pdfinfo was set in a configuration file
+	  if test ! -x "$pdfinfo"
+	  then
+	    if test $PDFJAM_CALL_NUMBER -eq 0
+	    then
+	      prattle \
+		"No pdfinfo utility at $pdfinfo, so --keepinfo is ignored."
+	      keepinfo=false
+	    fi
+	  fi
+	  ;;
+    esac
+    case "$iconv" in
+	"not found")
+	  if test $PDFJAM_CALL_NUMBER -eq 0
+	  then
+	    prattle \
+	      "The iconv utility was not found, so --keepinfo is ignored."
+	  fi
+	  keepinfo=false
+	  ;;
+	iconv)
+	  ;;
+	*)  ## $iconv was set in a configuration file
+	  if test ! -x "$iconv"
+	  then
+	    if test $PDFJAM_CALL_NUMBER -eq 0
+	    then
+	      prattle \
+		"No iconv utility at $iconv, so --keepinfo is ignored."
+	      keepinfo=false
+	    fi
+	  fi
+	  ;;
+    esac
+fi
+## A function to check if using non-Cygwin "${latex}" from Cygwin
+using_non_cygwin_latex_from_cygwin () {
+    if [ -z "${__cache__using_non_cygwin_latex_from_cygwin}" ]; then
+	if [ "$(uname -o)" = "Cygwin" ] \
+	    && "${latex}" -version | head -1 | grep -qv Cygwin; then
+	    __cache__using_non_cygwin_latex_from_cygwin=0
+	else
+	    __cache__using_non_cygwin_latex_from_cygwin=1
+	fi
     fi
-fi
+    return "${__cache__using_non_cygwin_latex_from_cygwin}"
+}
 ##
 ##  END OF CHECKING THE SETUP
 ##
@@ -988,9 +1043,9 @@
 fi
 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
+if using_non_cygwin_latex_from_cygwin; then
+    PDFJAM_TEMP_DIR=$(cygpath -w "$PDFJAM_TEMP_DIR")
+fi
 ##
 ##  TEMPORARY DIRECTORY ALL DONE
 ##
@@ -1116,10 +1171,11 @@
 	    uniqueName="source-$counter.pdf"
 	    uniqueName="$PDFJAM_TEMP_DIR"/"$uniqueName"
 	    ## Next is from the Cygwin patch contributed by Lucas
-	    case $(uname) in
-		*CYGWIN*) cp "$sourceFullPath" "$uniqueName";;
-		*) ln -s "$sourceFullPath" "$uniqueName";;
-            esac
+	    if using_non_cygwin_latex_from_cygwin; then
+		cp "$sourceFullPath" "$uniqueName"
+	    else
+		ln -s "$sourceFullPath" "$uniqueName"
+	    fi
 	    ;;
     esac
     filePageList="$filePageList","$uniqueName","$pageSpec"
@@ -1130,38 +1186,55 @@
 ##
 ##  Do the pdfinfo stuff (if relevant)...
 ##
-if  test "$hyperref" != false
-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');
+select_pdfinfo () {
+    printf '%s' "$2" | \
+    grep -e "^$1:" | \
+    sed -e 's/^'"$1"':\s*//'
+}
+echo_hex_iconv_utf16be () {
+    printf '%s' "$1" | \
+    "$iconv" -f utf8 -t utf16be | \
+    od -An -v -tx1 | \
+    tr -d '[:space:]'
+}
+echo_pdfinfodata () {
+    if [ -n "$2" ]; then
+	TMPA=$(echo_hex_iconv_utf16be "$2")
+	printf '%s' "/$1 <feff${TMPA}>"
     fi
-    if test -n "$pdfTitle" ; then
-	pdftitl="$pdfTitle"
-    fi
-    if test -n "$pdfAuthor" ; then
-	pdfauth="$pdfAuthor"
-    fi
-    if test -n "$pdfSubject" ; then
-	pdfsubj="$pdfSubject"
-    fi
-    if test -n "$pdfKeywords" ; then
-	pdfkeyw="$pdfKeywords"
-    fi
+}
+
+if test "$keepinfo" = true ; then
+    prattle "Calling ${pdfinfo}..."
+    PDFinfo=$(pdfinfo -enc UTF-8 "$uniqueName")
+    pdftitl=$(select_pdfinfo 'Title'    "$PDFinfo")
+    pdfauth=$(select_pdfinfo 'Author'   "$PDFinfo")
+    pdfsubj=$(select_pdfinfo 'Subject'  "$PDFinfo")
+    pdfkeyw=$(select_pdfinfo 'Keywords' "$PDFinfo")
 fi
+echo_iconv_from_enc () {
+    printf '%s' "$2" | \
+    "$iconv" -f "$1" -t utf8
+}
+if test -n "$pdfTitle" ; then
+    pdftitl=$(echo_iconv_from_enc "$enc" "$pdfTitle")
+fi
+if test -n "$pdfAuthor" ; then
+    pdfauth=$(echo_iconv_from_enc "$enc" "$pdfAuthor")
+fi
+if test -n "$pdfSubject" ; then
+    pdfsubj=$(echo_iconv_from_enc "$enc" "$pdfSubject")
+fi
+if test -n "$pdfKeywords" ; then
+    pdfkeyw=$(echo_iconv_from_enc "$enc" "$pdfKeywords")
+fi
+
+## Converting to PDF string
+raw_pdftitl=$(echo_pdfinfodata 'Title'    "$pdftitl")
+raw_pdfauth=$(echo_pdfinfodata 'Author'   "$pdfauth")
+raw_pdfsubj=$(echo_pdfinfodata 'Subject'  "$pdfsubj")
+raw_pdfkeyw=$(echo_pdfinfodata 'Keywords' "$pdfkeyw")
+
 ##
 ##  Now set up the files for latex...
 ##
@@ -1170,9 +1243,9 @@
 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
+if using_non_cygwin_latex_from_cygwin; then
+    filePageList=$(echo "$filePageList" | sed 's~\\~/~g')
+fi
 (cat <<EndTemplate
 \batchmode
 \documentclass[$documentOptions]{article}
@@ -1179,20 +1252,23 @@
 \usepackage{color} \definecolor{bgclr}{RGB}{$pagecolor} \pagecolor{bgclr}
 \usepackage[$papersize]{geometry}
 \usepackage[utf8]{inputenc}
-\usepackage{hyperref}
-\hypersetup{pdftitle={$pdftitl}}
-\hypersetup{pdfauthor={$pdfauth}}
-\hypersetup{pdfsubject={$pdfsubj}}
-\hypersetup{pdfkeywords={$pdfkeyw}}
+\ifdefined\luatexversion% LuaLaTeX
+  \protected\def\pdfinfo{\pdfextension info}
+\fi
+\ifdefined\XeTeXversion% XeLaTeX
+  \protected\def\pdfinfo#1{\AtBeginDvi{\special{pdf:docinfo << #1 >>}}}
+\fi
+\ifdefined\pdfinfo%
+  \pdfinfo{%
+    $raw_pdftitl %
+    $raw_pdfauth %
+    $raw_pdfsubj %
+    $raw_pdfkeyw %
+  }%
+\fi
 \usepackage{pdfpages}
 EndTemplate
     )  > "$texFile"
-if test "$hyperref" = false; then  ## we don't need hyperref
-    cp "$texFile" "$tempFile"
-    sed '/\\\usepackage{hyperref}/d' "$tempFile" | \
-	sed '/\\\hypersetup.*/d' > "${texFile}"
-    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"
@@ -1206,6 +1282,7 @@
 fi
 (cat <<EndTemplate
 $preamble
+$shortedge
 \begin{document}
 \includepdfmerge[$miscOptions]{$filePageList}
 \end{document}
@@ -1232,7 +1309,7 @@
 to try to diagnose the problem."
 i=1
 while [ "$i" -le "$runs" ] ; do
-    $latex "$texFile" > "$msgFile" || {
+    "$latex" "$texFile" > "$msgFile" || {
         prattle "$failureText"
         error_exit "Run $i: Output file not written" $E_SOFTWARE
     }
@@ -1276,7 +1353,10 @@
     error_exit "no write permission at ${outFile}" $E_CANTCREATE
 fi
 #fileSize=$(wc -c < "$fileName.pdf" | sed 's/^\ *//')
-if cat "$fileName".pdf > "$outFile" 2>/dev/null
+## Avoid explicit output to /dev/stdout.
+if test "$outFile" = "/dev/stdout" \
+   && cat "$fileName".pdf 2> /dev/null \
+   || cat "$fileName".pdf > "$outFile" 2>/dev/null
 then
     prattle "Finished.  Output was written to '${outFile}'."
 else



More information about the tex-live-commits mailing list.